Warning: Attempt to present ControllerA and ControllerB whose view is not in the window hierarchy!

来源:互联网 发布:精子优化处理检查 编辑:程序博客网 时间:2024/05/16 12:55

今天在写UIAlertController的时候,在ViewDidLoad中声明并模态推出的时候出现了一个错误:

Warning: Attempt to present <UIAlertController: 0x7f8691f12f80>  on <ViewController: 0x7f8691c38d20> which is already presenting <UIAlertController: 0x7f8691e93930>


这个错误网上查了一下,原因是在presnet的时候viewDidLoad还没有执行完成,只有viewDidLoad执行完成之后,正常使用。

在控制器加载的时候,不能使用这个去调用,这样就必须向办法延时才行。

由于是Demo,习惯性的直接写在viewDidLoad中,我最后使用一个Button来出发这个动作,就没有以上错误了。


1 0