【问题标题】:How a UINavigationController becomes navigationController of a UITableView?UINavigationController 如何成为 UITableView 的 navigationController?
【发布时间】:2016-04-07 15:21:49
【问题描述】:

当我通过将 UITableViewController 作为其根视图控制器传递来初始化 UINavigationController 时,我可以通过 UITableViewController 属性“navigationController”获取 UINavigationController。我想知道:

  1. 是否在初始化期间自动设置此类属性?
  2. navigationController 是 UITableViewController 或其父类实现的某个协议的属性吗?

【问题讨论】:

  • 没关系,可能会改变。
  • 您的意思是UINavigationController 而不是UINavigationBar?还有navigationController 而不是navigationBar
  • 这里似乎有很多混乱...... UINavigationBar 没有根视图控制器。 UITableView 不是视图控制器......你想要实现什么?
  • 你的意思是UITableViewController而不是UITableView
  • 显示代码,这样我们就不会在 cmets 中混淆:P

标签: ios objective-c uitableview uinavigationcontroller


【解决方案1】:

UINavigationController 呼叫[rootViewController didMoveToParentViewController:self]

通过这个方法,viewcontrollers 知道他们被添加到哪里了。

viewcontrollers 也有 getter parentViewControllernavigationController 只是方便获取器,将parentViewController 转换为UINavigationController *

【讨论】:

    猜你喜欢
    • 2011-07-03
    • 1970-01-01
    • 1970-01-01
    • 2014-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多