【问题标题】:UITableViewController subview: Tell pushViewController to owning UIViewControllerUITableViewController 子视图:告诉 pushViewController 拥有 UIViewController
【发布时间】:2010-02-09 17:39:04
【问题描述】:

我有一个UINavigationViewController,在其中我添加了一个UITableViewController 作为子视图。

我希望能够从 UITableViewController 内部告诉 UINavigationViewController pushViewController,但我无法检索正确的 navigationController 对象。

我已经尝试了in this thread 讨论的一些方法,但我无法获取视图的 navigationController。

有没有办法为子视图的“拥有”视图获取参考?

编辑:我能够做到这一点:

[[(MyAppDelegate *)[[UIApplication sharedApplication] delegate] mainViewController].navigationController pushViewController:oOptionsViewController animated:YES];

让它发挥作用。但问题只是我想在不一定知道navigationController的具体名称的情况下这样做(假设我有几个这样的实例,我使用相同的类,但它们可能用于其他导航控制器..)

【问题讨论】:

    标签: uinavigationcontroller uitableview


    【解决方案1】:

    我认为你在那里所做的很完美。

    navigationController 是一个实例变量,因此每个控制器实例都有自己的,并且可以根据添加到的导航元素将它们设置为不同的东西。

    稍后,
    布莱克。

    【讨论】:

      猜你喜欢
      • 2012-10-02
      • 2012-03-20
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 2010-12-13
      • 1970-01-01
      • 2016-05-03
      • 2014-02-07
      相关资源
      最近更新 更多