好吧,我想我不会轻易放弃 :) 这是我找到的解决问题的方法。由于我从模态视图控制器中呈现我的主要应用程序视图,这就是我所做的:
从 iOS 5 开始,每个视图控制器都有一个presentedViewController
属性。一旦你知道了,从那里开始就很容易了。这是 AppDelegate.m 中的一些特定代码
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if ([[userInfo objectForKey:@"notificationType"] isEqualToString: @"messageType"]) {
UITabBarController * tabBarController = (UITabBarController *)[self.window.rootViewController presentedViewController];
[tabBarController setSelectedIndex:kChatViewIndex];
// My view controller that I presented modally is a tabBar, your case can be different.
// ... so from here I can reach any navigation controller or any other view from inside my app
}
现在既然你已经有了你的视图控制器,你可以使用 setSelectedIndex: 如果它是一个 tabBarController,或者如果它是一个导航单元则推送某个视图控制器。
希望这可以帮助任何有类似问题的人。干杯!