在我的应用中,我将UINavigationController作为初始视图,
层次结构是这样的

UINavigationController-> LoginViewController
-> UITabBarController-> UINavigationController-> MasterViewController

MasterViewController本身具有tableView

当推送通知到来时,我在应用程序在后台工作时单击推送通知,然后应用程序打开masterViewController,问题是我想从推送通知中打开应用程序时更新MasterviewController中的tableList。

我尝试像这样从AppDelegate导航到MasterViewController

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

    UINavigationController * navController = (UINavigationController *) self.window.rootViewController;

    MasterViewController * masterController = [navController.viewControllers objectAtIndex:0];

    [masterController updateList];

    }

它不起作用,当我获得推送时如何更新MasterViewController?

谢谢

最佳答案

这也可以。

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

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    MasterViewController * masterController = [storyboard instantiateViewControllerWithIdentifier:@"Your_StoryboardID"];
[masterController updateList];
}

关于ios - 通过UITabBarController调用UIViewController进行推送,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21848261/

10-10 08:40