【发布时间】:2014-07-08 04:31:56
【问题描述】:
我在尝试链接我的 UIViewController 时遇到问题,但我得到了最后一个错误。
Attempt to present ViewController whose view is not in the window hierarchy
这是我的代码:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Wokay"])
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"Vibes"];
[self.window.rootViewController presentViewController:vc animated:YES completion:nil];
}
}
代码错误:
Warning: Attempt to present <ViewController: 0x110634bc0> on <Login: 0x10951e7f0> whose view is not in the window hierarchy!
【问题讨论】:
-
可以复制粘贴详细错误吗?
-
如果根视图控制器的视图当前不在窗口层次结构中,则不能这样做。
-
@highwing ,刚刚添加
-
@rdelmar ,当提醒弹出时,我唯一需要将它们重定向回来。
-
@user3546239 为什么必须从 rootViewController 呈现 vc?它不应该从当前视图控制器呈现吗?
标签: ios iphone objective-c xcode ios7