如何检测MoreController推送新的VC?

时间:2011-08-09 11:52:12

标签: iphone ios uitabbarcontroller

每当用户选择UITabBarController的不同选项卡时,我想调用某个方法。以下内容适用于选项卡栏上的实际选项卡,但不适用于更多控制器上的“选项卡”:

-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
     [self doSomethingWhenAnotherVCIsSelected]
}

只有在选择“标签”时才会调用此方法,包括“更多”标签。只要按下“更多”选项卡上的另一个VC,就不会调用它。

是否有任何标准通知机制可用于检测“更多”标签上是否选择了VC?

2 个答案:

答案 0 :(得分:1)

在viewController的-viewWillAppear中调用该方法。

答案 1 :(得分:0)

找到以下解决方法:

// subclass of UITabBarController
- (void)viewDidLoad
{
    moreDelegate=self.moreNavigationController.delegate;
    self.moreNavigationController.delegate=self;
    ...
}

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [moreDelegate navigationController:navigationController willShowViewController:viewController animated:animated];
}

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [moreDelegate navigationController:navigationController didShowViewController:viewController animated:animated];
    [self tabBarController:self didSelectViewController:viewController];
}