【问题标题】:NavigationController becomes nilNavigationController 变为 nil
【发布时间】:2015-03-28 00:34:53
【问题描述】:

我在我的根视图和子视图中嵌入了一个 navigationController,在我的一个子视图中我有:

@IBAction func button(sender: UIButton) {
    let tabBarController = UITabBarController()
    var tabs = [ItemViewController]()
    let tab = self.storyboard?.instantiateViewControllerWithIdentifier("itemViewController") as ItemViewController
    tabs += [tab]
    self.showViewController(tabBarController, sender: self)
}

按下按钮后,视图发生了变化,但我的 navigationController 变为 nil。我究竟做错了什么? :o

【问题讨论】:

  • ItemViewController 是导航控制器吗?
  • 不,它只是一个子视图
  • 奇怪的是,新视图似乎有一个导航栏,但我的自定义 leftbarbutton 没有显示。最重要的是,如果我添加更多 tabBarItems,在除第一个视图之外的所有视图中,导航栏将与我的 tableview 重叠

标签: swift uitabbarcontroller uinavigationbar


【解决方案1】:

您需要将导航控制器放入标签栏控制器——而不是导航控制器的根视图。

【讨论】:

  • 对不起,你有什么例子可以让我更容易理解吗?
  • 真的吗?只需给导航控制器一个标识符,然后使用它来代替您现在使用的视图控制器。
  • 这样做会显示错误的视图。我的故事板如下所示: UINavigationController -> MainView -> ItemViewController
猜你喜欢
  • 2011-02-07
  • 1970-01-01
  • 1970-01-01
  • 2020-05-11
  • 1970-01-01
  • 2020-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多