UIView (including subclasses) the timing of performing actions on several initializations

Source: Internet
Author: User
  • -(id)initWithFrame:(CGRect)frame-UIView the specified initialization method; Always send to UIView to initialize, unless it is loaded from a nib file;
  • -(id)initWithCoder:(NSCoder *)coder-Send this message to UIView when loaded from the nib file;
  • -(void)awakeFromNib-This message will be sent after initialization and connection of all the objects in the nib; Applies only to loading objects from the nib; If you want to override it, you must also call the parent class awakeFromNib ;
  • -(void)willMoveToSuperview:(UIView *)newSuperview-Send this message when a child view is about to be added to another view;
  • -(void)willMoveToWindow:(UIWindow *)newWindow-Sent when a view (or its Super view) will be added to the window;
  • -(void)didMoveToSuperview-Send this message after inserting a view into the view level;
  • -(void)didMoveToWindow-This message is sent when the view obtains its set of window properties.

Basically, you can choose: the actions performed during the initialization of your view (1 & 2), when loaded from the nib file (3), before being inserted into the view level (4 & 5) and after (6 & 7).

UIView (including subclasses) the timing of performing actions on several initializations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.