swift 中 awakeFromNib() 和 viewDidLoad() 之间的区别
difference between awakeFromNib() and viewDidLoad() in swift
我想知道 awakeFromNib() 和 viewDidLoad() 之间的主要区别,以便更清楚地了解它的工作原理。请问有人能解释一下吗?
来自 Apple 文档:
awakeFromNib
:
The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established.
参见:Nib Files in Resource Programming Guide
viewDidLoad
:
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.
我想知道 awakeFromNib() 和 viewDidLoad() 之间的主要区别,以便更清楚地了解它的工作原理。请问有人能解释一下吗?
来自 Apple 文档:
awakeFromNib
:
The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established.
参见:Nib Files in Resource Programming Guide
viewDidLoad
:
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.