Reputation: 6918
I am trying to segue to my ViewController with this code:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone_Storyboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"details"];
[self presentViewController:vc animated:YES completion:nil];
However I get this error message:
Warning: Attempt to present <MyViewController: 0x10c5771a0> on <UINavigationController: 0x10c533da0> whose view is not in the window hierarchy!
I am calling the segue in the UIAlertView Delegate Method:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
}
Upvotes: 0
Views: 797
Reputation: 66234
Your UIAlertView's window is the frontmost UIWindow, so your view controller can't present. You need to wait until the alert view dismisses. The simplest way is to use alertView:didDismissWithButtonIndex:
(instead of clickedButtonAtIndrx).
Upvotes: 2
Reputation: 901
add this too, it worked for me.
lvc.modalPresentationStyle = UIModalPresentationFormSheet;
lvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[mvc presentModalViewController:lvc animated:YES];
Upvotes: 0