ios7应用开发入门经典(第7版)p256页提到,对于modal类型的segue,可以通过presentingViewController和presentedViewController获取segue前后的controller。
但在ios8中实践发现presentingViewController返回了nil. 这是什么情况?查阅stackoverflow,得到如下答案:
When viewDidLoad is
called, there is no guarantee that the view controller hierarchy is loaded in the navigation tree. Moving the logic to a later stage (for example: viewWillAppear)
should resolve that issue as presentingController should
be loaded by then.
http://stackoverflow.com/questions/26081661/presentingviewcontroller-is-nil-when-using-presentviewcontrolleranimatedcomple
在iOS7的开发中,可以使用presentingViewController来获取模态 segue 前的控制器,但iOS8中实践发现此方法可能返回nil。这通常是由于在viewDidLoad时,视图控制器层级未加载完成。解决方案是将相关逻辑移到viewDidAppear之后,确保此时控制器已经被加载。
1177

被折叠的 条评论
为什么被折叠?



