我这里有这样的代码是想拍摄出警告:的Objective-C,其观点是不是在窗口层次! UIAlertController
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Message" message:@"Device is not valid." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
但我警告不会出现,我得到这个错误在我的控制台日志:
Attempt to present <UIAlertController: 0x134e5d350> on <ViewController: 0x135008c00> whose view is not in the window hierarchy!
我是什么做错了?我试图谷歌的解决方案,但我不明白他们中的任何一个。请帮忙。
什么是“自我”?你是一个视图控制器是视图栈上呈现'UIAlertController'? – JAL
您是否[尝试搜索错误](http://stackoverflow.com/search?q=whose+view+is+not+in+the+window+hierarchy+uialertcontroller)? – rmaddy
我试图把它呈现给视图控制器 –