我试图在我的Appdelegate.m文件中收到我的UILocalNotification时推送View.xib。但我的主根视图控制器是标签栏控制器。
我的代码无效,如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.applicationIconBadgeNumber = 0;
UILocalNotification *localNotif = [launchOptionsobjectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif)
{
NSLog(@"Recieved Notification %@\n",localNotif);
}
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_tabBarController = [[AKTabBarController alloc] initWithTabBarHeight: (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? 70 : 50];
[_tabBarController setViewControllers:[NSMutableArray arrayWithObjects:
navigationController,
navigationController2,
navigationController3,
nil]];
[_window setRootViewController:_tabBarController];
[_window makeKeyAndVisible];
return YES;
}
-(void)application:(UIApplication *)application
didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@"in didReceiveLocalNotification");
StartViewController2Track *viewController = [[StartViewController2Track alloc]initWithNibName:NSStringFromClass([StartVie Controller2Track class]) bundle:nil];
// [self.window.rootViewController presentViewController:viewController animated:YES completion:nil ];
// [self.navcontrol pushViewController:viewController animated:YES];
[self.rootViewController.tabBarController.selectedViewController.navigationController [pushViewController:StartViewController2Track animated]];
}
答案 0 :(得分:0)
你的rootviewcontroller是tabbarController。所以你试图从tabbarcontroller.tabbarcontroller
推出,而且selectedViewcontroller也是导航控制器。尝试以下..
[self.window.rootViewController.selectedViewController pushViewController:viewController animated:YES]];