【发布时间】:2010-01-07 20:05:36
【问题描述】:
我的应用程序中有一个 TabBar,我在 AppDelegate 中执行此操作:
...
test2ViewController = [[Test1ViewController alloc] init];
...
navigationTest2Controller = [[UINavigationController alloc] initWithRootViewController:test2ViewController];
NSArray *myControllers = [NSArray arrayWithObjects:..., navigationTest2Controller, nil];
[self.myTabBarController setViewControllers:myControllers animated:NO];
现在我有一个问题,我在 ViewController 中,我想切换到“navigationTest2Controller”。我在我的 AppDelegate 中这样做:
self.myTabBarController.selectedViewController = navigationTest2Controller;
这行得通。它切换到这个 ViewController!此 ViewController 已经加载,并且调用了 viewDidLoad 方法。在这个 viewDidLoad 方法中是一个方法调用:
[self myMethod];
我想要,如果视图切换到这个 ViewController,这个“myMethod”应该总是被调用。 我怎样才能做到这一点?在我的 AppDelegate 行之前
self.myTabBarController.selectedViewController = navigationTest2Controller;
???还是每次选择/切换 ViewController 时都会调用另一个委托?
有人知道吗?
非常感谢提前和最好的问候。
【问题讨论】:
标签: iphone uinavigationcontroller uitabbarcontroller delegates