我有一个UINavigationController的应用程序,它包含一个根UIViewController子类(PagingViewController),它管理和充当水平分页UIScrollView的代理。在这个UIScrollView的每个页面上,都有一个垂直滚动的UITableView,每个UITableView都由它自己的UIViewController子类(PageViewController)管理。它看起来是这样的......嵌套的UIViewController需要推到根UINavigationController
UINavigationController
PagingViewController (root VC of navigation controller)
PageViewController (instance 1)
PageViewController (instance 2)
PageViewController (instance 3)
HowToPushThisViewController (this is what I'd like to push onto the current root, PagingViewController, from one of its sub view controllers)
我希望做的是,在didSelectRowAtIndexPath方法:在PageViewController(UITableView的委托)的方法,推动了新的UIViewController到UINavigationController的(在PagingViewController的顶部)。
问题是PageViewController的navigationController属性为零,所以我不能将它推到那里。我认为这是零,因为它不直接在UINavigationController的堆栈上,但包含的PagingViewController,其中是在堆栈上。我尝试在将每个PageViewController的navigationController属性添加到PagingScrollView之前设置它的navigationController属性,但它似乎是只读的(UINavigationController如何设置它自己?)。我觉得嵌套的UIViewControllers是健全的体系结构(每个人都需要管理和充当其视图的委托),并且想要从子控制器中推导导航是合理的,所以我不确定最好的练习从嵌套控制器访问和推送。希望有一些简单的东西可以忽略,可以访问并推送到根naviagtion控制器。
或者,覆盖`-parentViewController`。这似乎允许一些UIViewController魔术工作,包括(我认为)-navigationController。伊西,不过! – 2010-11-23 04:33:47