警告:尝试在<uinavigationcontroller:0x10c533da0 =“”>上显示<myviewcontroller:0x10c5771a0 =“”>,其视图不在窗口层次结构中</uinavigationcontroller:> </myviewcontroller:>

时间:2014-01-01 03:35:46

标签: 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委托方法中调用segue:

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

}

2 个答案:

答案 0 :(得分:2)

您的UIAlertView窗口是最前面的UIWindow,因此您的视图控制器无法呈现。您需要等到警报视图解除。最简单的方法是使用alertView:didDismissWithButtonIndex:(而不是clickedButtonAtIndrx)。

答案 1 :(得分:0)

添加它,它对我有用。

lvc.modalPresentationStyle = UIModalPresentationFormSheet;
lvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

[mvc presentModalViewController:lvc animated:YES];