<legend id='9L1rm'><style id='9L1rm'><dir id='9L1rm'><q id='9L1rm'></q></dir></style></legend>
  • <small id='9L1rm'></small><noframes id='9L1rm'>

    • <bdo id='9L1rm'></bdo><ul id='9L1rm'></ul>
    <tfoot id='9L1rm'></tfoot>
  • <i id='9L1rm'><tr id='9L1rm'><dt id='9L1rm'><q id='9L1rm'><span id='9L1rm'><b id='9L1rm'><form id='9L1rm'><ins id='9L1rm'></ins><ul id='9L1rm'></ul><sub id='9L1rm'></sub></form><legend id='9L1rm'></legend><bdo id='9L1rm'><pre id='9L1rm'><center id='9L1rm'></center></pre></bdo></b><th id='9L1rm'></th></span></q></dt></tr></i><div id='9L1rm'><tfoot id='9L1rm'></tfoot><dl id='9L1rm'><fieldset id='9L1rm'></fieldset></dl></div>

      1. iOS 8 Swift 导航栏标题,按钮未显示在基于选项卡的应用程序中

        时间:2023-06-11

        1. <tfoot id='BE9VN'></tfoot>
            <tbody id='BE9VN'></tbody>

            <i id='BE9VN'><tr id='BE9VN'><dt id='BE9VN'><q id='BE9VN'><span id='BE9VN'><b id='BE9VN'><form id='BE9VN'><ins id='BE9VN'></ins><ul id='BE9VN'></ul><sub id='BE9VN'></sub></form><legend id='BE9VN'></legend><bdo id='BE9VN'><pre id='BE9VN'><center id='BE9VN'></center></pre></bdo></b><th id='BE9VN'></th></span></q></dt></tr></i><div id='BE9VN'><tfoot id='BE9VN'></tfoot><dl id='BE9VN'><fieldset id='BE9VN'></fieldset></dl></div>
              <bdo id='BE9VN'></bdo><ul id='BE9VN'></ul>
            • <small id='BE9VN'></small><noframes id='BE9VN'>

                <legend id='BE9VN'><style id='BE9VN'><dir id='BE9VN'><q id='BE9VN'></q></dir></style></legend>
                  本文介绍了iOS 8 Swift 导航栏标题,按钮未显示在基于选项卡的应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试遵循 本教程,这个答案 和 this answer 为我的每个标签创建导航栏在 iOS 8/Swift 中基于选项卡的应用程序中,但我的导航栏上没有显示标题或按钮.

                  I am trying to follow this tutorial, this answer, and this answer to create navigation bars for each of my tabs in a tab-based application in iOS 8 / Swift, but no title or buttons on my navigation bar are showing.

                  这是我目前所拥有的:

                  // AppDelegate.swift
                  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {            
                      let tabBarController = UITabBarController()
                  
                      let vc1 = ViewController()
                      let vc2 = ViewController()
                      let vc3 = ViewController()
                  
                      let nc1 = UINavigationController(rootViewController: vc1)
                      let nc2 = UINavigationController(rootViewController: vc2)
                      let nc3 = UINavigationController(rootViewController: vc3)
                  
                      let controllers = [nc1,nc2,nc3]
                  
                      tabBarController.viewControllers = controllers
                  
                      nc1.tabBarItem = UITabBarItem(title: "item1", image: nil, tag: 1)
                      nc2.tabBarItem = UITabBarItem(title: "item2", image: nil, tag: 1)
                      nc3.tabBarItem = UITabBarItem(title: "item3", image: nil, tag: 1)
                  
                      window = UIWindow(frame: UIScreen.mainScreen().bounds)
                      window?.rootViewController = tabBarController
                      window?.makeKeyAndVisible()
                  
                      return true
                  }
                  
                  // ViewController.swift
                  class ViewController: UIViewController, UINavigationBarDelegate {
                  
                      override func viewDidLoad() {
                          super.viewDidLoad()
                  
                          let navigationBar = UINavigationBar(frame: CGRectMake(0, 0, self.view.frame.size.width, 44))
                          navigationBar.backgroundColor = UIColor.blueColor()
                          navigationBar.delegate = self;
                  
                          let navigationItem = UINavigationItem()
                          navigationItem.title = "Title"
                  
                          let leftButton =  UIBarButtonItem(title: "Left Button", style:   UIBarButtonItemStyle.Plain, target: self, action: nil)
                          let rightButton = UIBarButtonItem(title: "Right Button", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
                  
                          navigationItem.leftBarButtonItem = leftButton
                          navigationItem.rightBarButtonItem = rightButton
                  
                          navigationBar.items = [navigationItem]
                  
                      }
                  
                      func positionForBar(bar: UIBarPositioning) -> UIBarPosition {
                          return UIBarPosition.TopAttached
                      }
                  }
                  

                  但我只是在模拟器顶部看到一个空白导航栏.

                  But I am just getting a blank navigation bar on top in the simulator.

                  推荐答案

                  您正在制作一个自定义 UINavigationBar,而 UINavigationController 已经提供给您.

                  You're making a custom UINavigationBar when one is already provided to you with the UINavigationController.

                  在你的 ViewController 中试试这个:

                  Try this instead in your ViewController:

                  override func viewDidLoad() {
                      super.viewDidLoad()
                  
                      self.title = "Title"
                  
                      let navigationBar = navigationController!.navigationBar
                      navigationBar.tintColor = UIColor.blueColor()
                  
                      let leftButton =  UIBarButtonItem(title: "Left Button", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
                      let rightButton = UIBarButtonItem(title: "Right Button", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
                  
                      navigationItem.leftBarButtonItem = leftButton
                      navigationItem.rightBarButtonItem = rightButton
                  }
                  

                  这篇关于iOS 8 Swift 导航栏标题,按钮未显示在基于选项卡的应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何创建像 BestBuy App 这样的自定义导航栏? 下一篇:禁用后退按钮并将取消按钮放在导航视图控制器中 - 就像联系人 iPhone 应用程序

                  相关文章

                  <i id='oAAhL'><tr id='oAAhL'><dt id='oAAhL'><q id='oAAhL'><span id='oAAhL'><b id='oAAhL'><form id='oAAhL'><ins id='oAAhL'></ins><ul id='oAAhL'></ul><sub id='oAAhL'></sub></form><legend id='oAAhL'></legend><bdo id='oAAhL'><pre id='oAAhL'><center id='oAAhL'></center></pre></bdo></b><th id='oAAhL'></th></span></q></dt></tr></i><div id='oAAhL'><tfoot id='oAAhL'></tfoot><dl id='oAAhL'><fieldset id='oAAhL'></fieldset></dl></div>
                  1. <tfoot id='oAAhL'></tfoot>

                  2. <legend id='oAAhL'><style id='oAAhL'><dir id='oAAhL'><q id='oAAhL'></q></dir></style></legend>

                        <bdo id='oAAhL'></bdo><ul id='oAAhL'></ul>

                      <small id='oAAhL'></small><noframes id='oAAhL'>