When I create a label in Interface Builder and hook the outlet to a viewController, and log the label in viewDidLoad as follows:
NSLog(@”label: %@”,self.label);
It gives me a frame of (0,0,0,0). self.view gives me a size over 0. An older program’s label also gives me a size over 0. It will log the text in the label, so it is hooked up right. Is this a change in Xcode 4.5? How do I access the frames that I set in Interface Builder?
this is the log:
UILabel: 0x754e1b0; frame = (0 0; 0 0); text = ‘this is a label’; clipsToBounds = YES; opaque = NO; autoresize = TM+BM; userInteractionEnabled = NO; layer =…
Usually the frame layouts are unreliable in
viewDidLoad. In the case of a nib this shouldn’t be a problem. Are you using AutoLayout by any chance ?Please also log the same values in
viewWillAppear, this will certainly have the correct values. I usually useviewWillLoadto initiate my UI elements, andviewWillLoadto place them correctly.