iphone - Why are controls (null) in awakeFromNib? -


this follow on question regarding why not set uicontrols in awakefromnib. answer can see below controls nil in awakefromnib, although initialised correct objects time viewdidload. setup view same do, should doing different access them here, xib(nib) designed , saved current version of image builder.

code:

@interface iphone_test_awakefromnibviewcontroller : uiviewcontroller {     uilabel *mylabel;     uiimageview *myview; } @property(nonatomic, retain)iboutlet uilabel *mylabel; @property(nonatomic, retain)iboutlet uiimageview *myview; @end 

.

@synthesize mylabel; @synthesize myview;  -(void)awakefromnib {     nslog(@"awakefromnib ...");     nslog(@"mylabel: %@", [mylabel class]);     nslog(@"myview : %@", [myview class]);     //[mylabel settext:@"awake"];     [super awakefromnib];  }  -(void)viewdidload {     nslog(@"viewdidload ...");     nslog(@"mylabel: %@", [mylabel class]);     nslog(@"myview : %@", [myview class]);     //[mylabel settext:@"view"];     [super viewdidload]; } 

output:

awakefromnib ... mylabel: (null) myview : (null) viewdidload ... mylabel: uilabel mylabel: uiimageview 

much appreciated ...

gary

iboutlet connect control subview of view

and view lazy load

so can access first following:

func awakefromnib() {     super.awakefromnib()     let _ = self.view     println("\(self.mylabel)") } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -