我已经编写了下面的代码,在UIViewController
的{{1}}之上展示了一个模态UISplitViewController
。但是,它不断抛出AppDelegate
。
Application tried to present modally an active controller <UISplitViewController: 0x138023800>.
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
NSLog(@"%@", shortcutItem.type);
if([shortcutItem.type isEqualToString:@"com.myapp.show-me"]){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UISplitViewController *tc = [storyboard instantiateViewControllerWithIdentifier:@"SplitViewController"];
self.window.rootViewController = tc;
UINavigationController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"Navigation"];
UIViewController *detailViewController = [ivc.viewControllers objectAtIndex:0];
detailViewController.restaurant = @"1";
[tc presentViewController:detailViewController animated:YES completion:nil];
} else if([shortcutItem.type isEqualToString:@"com.myapp.see-all"]){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UISplitViewController *tc = [storyboard instantiateViewControllerWithIdentifier:@"SplitViewController"];
self.window.rootViewController = tc;
}
}
我做错了什么?
答案 0 :(得分:0)
事实证明,我只需要提供UINavigationController
而不是UIViewController
。
[tc presentViewController:ivc animated:YES completion:nil];