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.
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.
相关文章推荐
- iOS 中的视图函数 init initwithnib viewDidLoad viewWillAppear的总结
- iOS -- loadView/viewDidLoad/initWithNibName/awakeFromNib/initWithCoder的用法
- iphone+ios+loadView/viewDidLoad/initWithNibName/awakeFromNib/initWithCoder/initWithFrame
- IOS 视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear等的区别及用途
- iOS 生命周期 -init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear 区别和用途
- iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用途
- 【iOS知识学习】_视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear等的区别及用途
- [[ViewController alloc]init]与[ViewController alloc]initWithNibName: bundle: ]的区别;
- iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用
- 【iOS知识学习】_视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear等的区别及用途
- IOS开发之界面生命周期——init,viewDidAppear,viewWill(dis)Appear,loadView,viewDid(un)Load,dealloc
- iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用途
- iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用途
- iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用
- 总结Nib(xIB)、File's owner、NSBundle、loadView/viewDidLoad、initWithNibName的相关基础知识
- IOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用途
- 『IOS』loadView、viewDidLoad、initWithCoder、initWithNibName、awakeFromNib的用法
- iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用途
- 【iOS知识学习】_视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear等的区别及用途
- iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用途