【发布时间】:2019-09-13 14:57:17
【问题描述】:
当我尝试从我的应用程序中显示 UIAlertController 时,应用程序终止并出现异常 UIViewControllerHierarchyInconsistency。
视图控制器是使用故事板创建的
我创建并(尝试)像这样显示警报:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *yesButton = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
...
}];
[alert addAction:yesButton];
[self presentViewController:alert animated:YES completion:nil];
但是,在执行期间,我在输出中得到了这个:
2016-08-25 09:46:07.536 TrackYou[10554:3165715] *** 由于未捕获的异常“UIViewControllerHierarchyInconsistency”而终止应用程序,原因:“子视图控制器:
<UICompatibilityInputViewController:0x13f5afd80> 应该有父视图控制器:<ViewController: 0x13f549360> 但请求的父级是:<UIInputWindowController: 0x140043c00>'
从同一个ViewController 我使用presentViewController 来展示一个自定义的ViewController,它工作正常。
SettingsViewController *controller = [SettingsViewController new];
[self presentViewController:controller animated:YES completion:nil];
任何想法是什么导致了问题?
【问题讨论】:
标签: ios objective-c xcode