在一个block中进行了present vc的行为,结果present失败,出现了warning:
Warning: Attempt to present on whose view is not in the window hierarchy!
在多方查找验证之后,发现下边方案可以解决此问题:
将之前present的语句换成下边的语句
UIViewController *mviewController = [UIApplication sharedApplication].keyWindow.rootViewController;
if (mviewController.presentedViewController) {
[mviewController.presentedViewController dismissViewControllerAnimated:false completion:^{
[mviewController presentViewController:nav animated:YES completion:nil];
}];
}else {
[mviewController presentViewController:nav animated:YES completion:nil];
}
其中的nav时之前创建好的用于present的UINavigationController实例
希望对你有用~