objective-c 中从 UIApplicationShortcutItem 打开故事板视图控制器的正确实现
Correct implementation of opening storyboard view controller from UIApplicationShortcutItem in objective-c
这是我尝试从故事板打开视图控制器时获得的代码。我在
上收到错误 "expected identifier"
UINavigationController controller = [(UINavigationController)[[mainStoryboard instantiateViewControllerWithIdentifier: @"ARViewController"];
有人可以帮忙吗。
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
NSLog(@"%@", shortcutItem.type);
if ([shortcutItem.type isEqualToString:@"ADD OWN STRING HERE"]) {
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UINavigationController *controller = [(UINavigationController*)[[mainStoryboard instantiateViewControllerWithIdentifier: @"ARViewController"]];
[navigationController pushViewController:controller animated:YES];
}
}
@end
您的 [
和 ]
的数量和位置不匹配(两个 [
太多,一个 ]
太多)。应该是:
UINavigationController *controller = (UINavigationController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"ARViewController"];
这是我尝试从故事板打开视图控制器时获得的代码。我在
上收到错误 "expected identifier"UINavigationController controller = [(UINavigationController)[[mainStoryboard instantiateViewControllerWithIdentifier: @"ARViewController"];
有人可以帮忙吗。
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
NSLog(@"%@", shortcutItem.type);
if ([shortcutItem.type isEqualToString:@"ADD OWN STRING HERE"]) {
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UINavigationController *controller = [(UINavigationController*)[[mainStoryboard instantiateViewControllerWithIdentifier: @"ARViewController"]];
[navigationController pushViewController:controller animated:YES];
}
}
@end
您的 [
和 ]
的数量和位置不匹配(两个 [
太多,一个 ]
太多)。应该是:
UINavigationController *controller = (UINavigationController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"ARViewController"];