I want display different UIButton/UILabel/UISlider sizes on an iPhone 4/4s screen. In the parent ViewController viewDidAppear: method I was able to set new button frames by calling my viewFormatting function.
- (void) viewFormatting
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
//iPhone 4
if (result.height == 480)
{
self.myButton.frame = CGRectMake(x, y, width, height);
self.myLabel.frame = CGRectMake(x, y, width, height);
//etc.
}
}
}
But when I try calling the same method viewFormatting inside initWithFrame: on separate UIView class the button/label frames do not resize. I also tried calling the function inside layoutSubviews. I put a NSLog inside viewFormatting so I know it is getting called correctly, but the button/label frames do not change.
Note: In both scenarios I have created the outlets in XIB files.
Any help is greatly appreciated!