ios awakeFromNib 和 initWithCoder:
During the instantiation process, each object in the archive is unarchived and then initialized with the method befitting its type. Objects that conform to the NSCoding
protocol (including all subclasses of UIView
and UIViewController
) are initialized using their initWithCoder:
method. All objects that do not conform to the NSCoding
protocol are initialized using their init
method. After all objects have been instantiated and initialized, the nib-loading code reestablishes the outlet and action connections for all of those objects. It then calls the awakeFromNib
method of the objects. For more detailed information about the steps followed during the nib-loading process, see Nib Files in Resource Programming Guide.