didFinishLaunchingWithOption和viewDidLoad之间有什么区别 [英] What are the differences between didFinishLaunchingWithOption and viewDidLoad

查看:138
本文介绍了didFinishLaunchingWithOption和viewDidLoad之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两种方法有什么区别 didFinishLaunchingWithOption viewDidLoad

What is the difference between the two methods didFinishLaunchingWithOption and viewDidLoad?

前者是 AppDlegate.m
的方法,后者是 ViewController.m的方法,但它们都执行将UI加载到视图上的相同任务。

The former is a method of AppDlegate.m and the latter is a method of ViewController.m, but both of them perform the same mission of loading the UIs onto the view.

推荐答案

application:didFinishLaunchingWithOptions:是一个 UIApplicationDelegate 协议方法,当iOS完成设置应用程序运行区域时调用该方法是开发人员加载视图控制器等的插入点。

The application:didFinishLaunchingWithOptions: is a UIApplicationDelegate protocol method that gets called when iOS has finished setting up an area for your App to run and is the insertion point for you, the developer, to load a view controller, etc.

viewDidLoad 方法另一方面是 UIViewController 类的一种方法,当一个 UIViewController 的实例将其视图加载到内存中时,它会被调用。从Apple的文档中:

The viewDidLoad method on the other hand is a method of the UIViewController class that gets called when an instance of UIViewController gets its view loaded into memory. From Apple's documentation:


在控制器的视图加载到内存后调用。

Called after the controller’s view is loaded into memory.

讨论
在视图控制器将其视图层次结构加载到内存后调用此方法。无论视图层次结构是从nib
文件加载还是在loadView方法中以编程方式创建,都会调用此方法
。您通常
重写此方法以对从nib文件加载的视图
执行其他初始化。

Discussion This method is called after the view controller has loaded its view hierarchy into memory. This method is called regardless of whether the view hierarchy was loaded from a nib file or created programmatically in the loadView method. You usually override this method to perform additional initialization on views that were loaded from nib files.

这篇关于didFinishLaunchingWithOption和viewDidLoad之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆