我不断收到此警告,无论我尝试什么,我都不确定如何解决它。
Attempt to present <LoginViewController: 0x1f0b5010> on <ViewController: 0x1dda1670> whose view is not in the window hierarchy!
我的 Storyboard中没有segue,因为我以编程方式调用模态视图:
//Load Login View if no username is found
NSLog(@"No username found");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
LoginViewController *loginView = (LoginViewController *)
[storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
[self presentViewController:loginView animated:YES completion:nil];
这是我的 Storyboard的图像:
谢谢!!!
最佳答案
如果您尝试在 ViewDidload
中呈现 View ,会产生错误。
如果你想使用它,你可以使用 performselector
而不是延迟调用此代码。
关于iphone - 呈现模态视图总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16395680/