从App Delegate获取特定的tabView对象

时间:2015-04-14 18:31:55

标签: ios objective-c uitabbarcontroller uitabbar appdelegate

尝试在收到通知时从应用代理启动特定的tabView对象,但应用程序在启动时崩溃。

以下是代码:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController;
CustomTabViewController  * tabBar = [[CustomTabViewController alloc] init];
NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];


NSString *type = [notificationPayload objectForKey:@"type"];

if([type isEqualToString:@"friend"]){

    tabBar.selectedViewController = [tabBar.viewControllers objectAtIndex:2];
    self.window.rootViewController = tabBar;
    [self.window makeKeyAndVisible];


}

if([type isEqualToString:@"message"]){
    tabBar.selectedViewController = [tabBar.viewControllers objectAtIndex:0];
    self.window.rootViewController = tabBar;
    [self.window makeKeyAndVisible];

}

有什么想法吗?

0 个答案:

没有答案