【纠错】视图跳转的几个常见警告以及解决方案

最近智商一不小心就拙急了一下。老范晕,遇到几个细节问题硬是憋了我半天。总结一下:

我使用的故事版 

跳转的方式是连接两个需要跳转的ViewController,然后根据id使用[self performSegueWithIdentifier:@"*id" sender:nil];进行跳转

(故事版的话,我是比较喜欢这种方式,虽然会多谢几行代码,但是灵活性提升很多。)

跳转倒是没问题,但是会出现警告。当时真是不明觉厉。

1、Warning: Attempt to present *viewController  on *viewController  while a presentation is in progress!

2、Warning: Attempt to dismiss from view controller *viewController while a presentation or dismiss is in progress!
然后自己鼓捣了一上午,把第一个警告鼓捣成了

Warning: Attempt to present *viewController on *viewController whose view is not in the window hierarchy!

这尼玛坑爹!

最后发现原因是自己想

跳转的方式是连接两个需要跳转的ViewController,然后根据id使用[self performSegueWithIdentifier:@"*id" sender:nil];进行跳转

结果,因为后来多增加了一个跳转选项,而自己在连线的时候一时脑昏直接连了按钮。

也就是说,同时进行了多次present,导致了警告。

检讨自己的同时,与大家共勉。

原文地址:https://www.cnblogs.com/anjohnlv/p/3396304.html