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