您的位置:首页 > 移动开发

ios view的几种加载函数的区别didFinishLaunchingWithOptions、initWithNibName:bundle、loadView、viewWillAppear

2014-07-17 16:17 489 查看
application:didFinishLaunchingWithOptions: is where you instantiate and set an

application’s root view controller.

This method gets called exactly once when the application has launched. Even if you go to

another app and come back, this method does not get called again. If you reboot your phone and

start the app again, application:didFinishLaunchingWithOptions: will get called again.

initWithNibName:bundle: is the designated initializer for UIViewController.

When a view controller instance is created, its initWithNibName:bundle: gets called once. Note

that in some apps, you may end up creating several instances of the same view controller class.

This method will get called once on each as it is created.

loadView: is overridden to create a view controller’s view programmatically.

• viewDidLoad can be overridden to configure views created by loading a NIB file. This method

gets called after the view of a view controller is created.

viewWillAppear: can be overridden to configure views created by loading a NIB file.

This method and viewDidAppear: will get called every time your view controller is moved on

screen. viewWillDisappear: and viewDidDisappear: will get called every time your view

controller is moved offscreen. So if you launch the app you are working on and hop back and

forth between Hypnosis and Reminder, BNRReminderViewController’s viewDidLoad method will

be called once, but viewWillAppear: will be called dozens of times.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐