Why are controls (null) in awakeFromNib?
- by fuzzygoat
This is a follow on from another question regarding why I could not set UIControls in awakeFromNib. The answer to that is that as you can see below the controls are nil in the awakeFromNib, although they are initialised to the correct objects by the time we get to viewDidLoad. I setup the view the same as I always do, should I be doing something different to access them here, the xib(nib) was designed and saved with the 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