ios - 警告 : Attempt to present <MyViewController: 0x10c5771a0> on <UINavigationController: 0x10c533da0> whose view is not in the window hierarchy

标签 ios objective-c segue

我正在尝试使用此代码连接到我的 ViewController:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone_Storyboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"details"];
[self presentViewController:vc animated:YES completion:nil];

但是我收到此错误消息:

Warning: Attempt to present <MyViewController: 0x10c5771a0> on <UINavigationController: 0x10c533da0> whose view is not in the window hierarchy!

我在 UIAlertView 委托(delegate)方法中调用 segue:

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{

}

最佳答案

您的 UIAlertView 的窗口是最前面的 UIWindow,因此您的 View Controller 无法呈现。您需要等到警报 View 消失。最简单的方法是使用 alertView:didDismissWithButtonIndex:(而不是 clickedButtonAtIndrx)。

关于ios - 警告 : Attempt to present <MyViewController: 0x10c5771a0> on <UINavigationController: 0x10c533da0> whose view is not in the window hierarchy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20865327/

相关文章:

ios - 保护随 iPhone 应用程序分发的数据

html - 图像未显示 iPhone(在包括 Android 在内的所有设备上均正常)

ios - 安装 XCode 4.5 会删除 iOS Simulator 5.1 吗?

iPhone Storyboard,以编程方式调用 segues,导航问题

ios - Xcode 7 UI 测试,录制按钮显示为灰色

ios - 如何以编程方式在 TableView 页脚中为 UIView 设置约束?

ios - id delegate unrecognized selector 发送到实例

iphone - 如何将字符串从 Objective-C 传递给 C 函数并取回值?

ios - 如何使用 Swift 在 iOS 中从右到左呈现 View Controller

iOS segue 在显示新 View 之前卡住多秒