gpt4 book ai didi

iphone - didFinishLaunchingWithOption 和 viewDidLoad 有什么区别

转载 作者:行者123 更新时间:2023-12-03 18:45:04 25 4
gpt4 key购买 nike

didFinishLaunchingWithOptionviewDidLoad 这两个方法有什么区别?

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

最佳答案

application:didFinishLaunchingWithOptions: 是一个 UIApplicationDelegate 协议(protocol)方法,当 iOS 完成为您的应用程序运行设置区域时调用该方法,并且是您的插入点,开发人员,加载 View Controller 等。

另一方面,viewDidLoad 方法是 UIViewController 类的一个方法,当 UIViewController 实例加载其 View 时调用该方法进入内存。来自苹果的文档:

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

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.

关于iphone - didFinishLaunchingWithOption 和 viewDidLoad 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13053230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com