Before I get into the details I want to mention that I've tried all the tutorials about adding LaunchImages/LaunchScreen.xib, etc. and none of that has worked for me. Maybe I did something wrong so please let me know if you think I missed something.
So most of my views are created using Interface Builder/Auto Layout and they scale to the right size for all the emulators, iPhone 4s-iPhone 6s plus.
However, for one of my views I do it a little bit differently, and it seems to stay at the iPhone 4S screen size regardless of which emulator I run it on. (Aka it has white space around the view)
Here's what I do:
I have a CustomView.XIB and I added a bunch of buttons/labels/etc using AutoLayout.
I also make CustomView.h and .m files:
- (instancetype)initWithNib {
self = [super initWithFrame:[[UIScreen mainScreen] bounds]];
if (self) {
NSLog(@"Screen bounds height in view: %f",[UIScreen mainScreen].bounds.size.height);
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
UINib *nib = [UINib nibWithNibName:@"CustomView" bundle:bundle];
CustomView *view = [nib instantiateWithOwner:self options:nil][0];
[self addSubview:view];
}
return self;
}
and in my CustomViewController.m file i have:
currentCustomView = [[CustomView alloc] initWithNib];
[self.view addSubview:currentCustomView];
So actually I don't think the [[UIScreen mainScreen] bounds] is wrong. Both the CustomViewController and the CustomView returns the same incorrect bound. Why is the ViewController's bounds incorrect? Why is it always the iPhone 4s bounds rather than changing with different emulators?
I have my Launch images in images assets:
And in the properties section:
Another question: If I am only supporting IOS 9 and above, it would seem to me that I don't need the iOS 6 and Prior launch images. BUT then it wouldn't work correctly on some emulator versions. But I thought all iPhones 4s-6s can support iOS9 so why do they set it up like this?
JUST figured out how to do this after 2 DAYS of trying out different things.
For people who read this, dont even worry about launch images and all that jazz. Just use AutoLayout and it will scale views in your viewcontroller for you. I just had to do:
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
And then the NSLayoutConstraints I want. But the key is I need to do this for both the CustomViewController AND inside my CustomView after I add the subview. Take a look at my code above to see why I need to do this.