![](/img/trans.png)
[英]How to change view controller to tab bar controller as root view controller
[英]how to push view.xib on UILocalNotification receive when Root view controller is Tab bar controller?
当我的UILocalNotification收到Appdelegate.m文件时,我试图推送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]];
}
您的rootviewcontroller是tabbarController。 因此,您尝试从tabbarcontroller.tabbarcontroller
推送,并且selectedViewcontroller也是导航控制器。 尝试下面..
[self.window.rootViewController.selectedViewController pushViewController:viewController animated:YES]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.