ObjC - presentViewController 中断
ObjC - presentViewController breaks
我正在尝试以编程方式显示另一个视图控制器。我写了一些我从例子中学到的代码,它没有给出错误。但它中断并以绿色显示:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); thread 1 : signal SIGABRT
我使用了这个代码:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"secondViewController"];
[self presentViewController:vc animated:NO completion:nil];
是我的代码有问题,还是其他原因?
提前致谢。
发生这种情况可能是因为您的情节提要中没有情节提要 ID 为 secondViewController 的 UIViewController。
您可以将 UIViewcontroller 拖到 Storyboard 中,然后在 Identity inspector 中将 Storyboard ID 设置为 secondViewController。
见下图
希望对您有所帮助:)
我正在尝试以编程方式显示另一个视图控制器。我写了一些我从例子中学到的代码,它没有给出错误。但它中断并以绿色显示:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); thread 1 : signal SIGABRT
我使用了这个代码:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"secondViewController"];
[self presentViewController:vc animated:NO completion:nil];
是我的代码有问题,还是其他原因?
提前致谢。
发生这种情况可能是因为您的情节提要中没有情节提要 ID 为 secondViewController 的 UIViewController。
您可以将 UIViewcontroller 拖到 Storyboard 中,然后在 Identity inspector 中将 Storyboard ID 设置为 secondViewController。 见下图
希望对您有所帮助:)