我這裏有這樣的代碼是想拍攝出警告:的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
我試圖把它呈現給視圖控制器 –