我想在我的iOS应用程序的AppDelegate中显示一个UIAlertController
。
以下是警报和present方法。
UIAlertController *alert = [UIAlertController alertControllerWithTitle:cTitle message:cMessage preferredStyle:UIAlertControllerStyleAlert];
//Configure alert and actions
[self.window.rootViewController presentViewController:alert animated:TRUE completion:nil];
然而,当我尝试展示警告时,它没有出现,而我在控制台中得到了以下警告。
Warning: Attempt to present <UIAlertController: 0x145f5d60> on <UINavigationController: 0x146590f0> whose view is not in the window hierarchy!
什么导致了这个错误,我该怎么修复它?