UIView - How to receive notifications when loading a view?

Is there something similar to viewDidLoad of UIViewController for a UIView ??? I need to be notified as soon as the UIView ( UIView Subclass) UIView , and follow some steps.

+64
ios objective-c iphone uiview viewdidload
Dec 21 '10 at 17:13
source share
1 answer

Depending on what actions you need to perform, there are several methods:

  • -(id)initWithFrame:(CGRect)frame - the UIView initializer is designated; always sent to UIView to initialize it, if only the view is loaded from the bottom;
  • -(id)initWithCoder:(NSCoder *)coder - always sent to initialize UIView whenever a view is loaded from nib;
  • -(void)awakeFromNib - is dispatched after all objects in nib are initialized and connected; applicable only when loading an object from a tip; you must call super;
  • -(void)willMoveToSuperview:(UIView *)newSuperview - is sent immediately before the view is added as a view to another view; newSuperview may not be present when you delete a view from your supervisor;
  • -(void)willMoveToWindow:(UIWindow *)newWindow - is sent immediately before the view (or its inscription) to the window; newWindow may be absent when you remove a view from a window;
  • -(void)didMoveToSuperview - sent immediately after inserting the view into the view hierarchy;
  • -(void)didMoveToWindow - -(void)didMoveToWindow immediately after the view receives its window property. -

In principle, you can perform your actions during initialization (1 and 2) after loading from the nib (3) before inserting views (4 and 5) into the hierarchy and after that (6 and 7).

+223
Dec 21 '10 at 18:44
source share



All Articles