【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方法的。