![](/img/trans.png)
[英]How to navigate to a view controller on a new storyboard file in objective-c
[英]Correct implementation of opening storyboard view controller from UIApplicationShortcutItem in objective-c
這是我試圖從情節提要中打開視圖控制器的代碼。 我收到錯誤消息“預期標識符”
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"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.