0

我需要从应用程序委托中选择选项卡上的索引,并在视图控制器中调用该选项卡在情节提要中映射到的函数

(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

     NSString *alertMessage = [[userInfo objectForKey:@"aps"] valueForKey:@"alert"];

    if (alertMessage != nil){
         UITabBarController *tabb = (UITabBarController *)self.window.rootViewController;
        tabb.selectedIndex = 2;
     // Need to call a method in my SpecialsViewController which manages properties and functions of tab with index 2
    }
}
4

1 回答 1

0

请执行下列操作

UITabBarController *tabb = (UITabBarController *)self.window.rootViewController;
UIViewController *controller = [tabb.viewControllers objectAtIndex:index_of_your_view_ SpecialsViewController];
[controller call_your_method];

在你的情况下index_of_your_view_ SpecialsViewController = 2

于 2012-06-06T19:34:42.407 回答