0

我创建了一个视图控制器,然后创建了一个导航控制器:

initWithRootViewController:

然后我观察到它调用pushViewController:animated:,因为我使用自己的UINavigationController子类,所以我覆盖pushViewController:animated:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [super pushViewController:viewController animated:animated];
    // do something with the VC
}

问题是,紧接着

[super pushViewController:viewController animated:animated];

否,所以我实际上不能做我想做的viewController.isViewLoaded事,当它用作导航控制器的根 VC 时,有没有办法强制加载 VC?

谢谢!

编辑,下面是代码:

MyViewController *vc = [[MyViewController alloc] initWithNib:@"" bundle:nil];
MyNavController *nav = [[MyNavController alloc] initWithRootViewController:vc];

self.revealViewController.frontViewController = nav;
4

2 回答 2

1
Access view before pushing viewController.

[viewController view];//this will load your view
[super pushViewController:viewController animated:animated];
于 2012-12-10T04:19:46.300 回答
1

我在 Apple 文档中找到了这个答案

UINavigationController 类实现了一个专门的视图控制器来管理分层内容的导航。此类不用于子类化。

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

于 2012-12-10T03:46:42.073 回答