I'm working with an old Xcode project which is roughly 7/8 years old and I've migrated it to Objective-C 2.0 and to support ARC. The project didn't support Auto-Layout (this was just before it was released) prior to me working on it. I've managed to clear up a lot of the errors/issues i was having with running it in a more modern Xcode IDE (10.2.1). For testing purposes I have implemented this code into the AppDelegate
:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
[self.window setBackgroundColor:[UIColor redColor]];
self.window.rootViewController = [UIViewController new];
[self.window makeKeyAndVisible];
return YES;
}
which gives me this for some reason:
This is the result when i run on a iPhone X, iPhone XR or iPhone XS Max, it looks like the top and bottom margins (safe areas) of the screen are not being picked up on. When i debug the view hierarchy they aren't being picked up on either, it just shows the red space? When i throw this code in a new project it works fine and fills up all the space. I'm wondering that because this is a old project there might be a build setting which is restricting the UIWindow
from expanding to allow support for new devices?
Also as a side note I've made sure the UIWindow
object isn't being manipulated elsewhere.