viewDidAppear在何時調用?


viewDidAppear在何時調用

  If the view belonging to a view controller is added to a view hierarchy directly, the view controller will not receive this message. If you insert or add a view to the view hierarchy, and it has a view controller, you should send the associated view controller this message directly. Failing to send the view controller this message will prevent any associated animation from being displayed.

  如果包含在一個viewController中的view被直接添加到一個view上,就像這樣:
  [view1 addSubView: viewController.view];

  這樣我們的viewController就不會收到viewDidAppear:的消息。按這種方式添加視圖的話,我們一般需要手動發送這個消息,也就是調用viewController的viewDidAppear方法。否則的話相關的動畫都無法正常顯示。

  像navigationController的push,或者是presentModelViewController的方法不屬於上述方式。而且有明顯的動畫顯示(彈出效果),個人認為是自動調用viewDidAppear方法的。

 

參考:http://www.cocoachina.com/bbs/simple/?t17845.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM