iosobjective-cios-autolayoutios8.1visual-format-language

Auto Layout broken on iOS 8.1


I'm working with Auto Layout Visual Format Language and using the following expressions:

They work fine in 9 and 10, but in iOS 8.1 we noticed that the layout is not working as expected. The view is getting the double of dimensions.

The testing code im using:

Thanks in advance


Solution

  • This bug appears to be caused in your app delegate, by initializing the window and calling makeKeyAndVisible before it has a frame. Replace this line:

    self.window = [UIWindow new];
    

    With an explicit frame on initialization:

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    

    ...and remove the redundant line setting the window's frame afterwards. Alternatively you could move the call to makeKeyAndVisible after the setting the window's frame, ie:

    if (initViewController)
    {
        self.window = [UIWindow new];
        self.window.rootViewController = initViewController;
        self.window.frame = [[UIScreen mainScreen] bounds];
        [self.window makeKeyAndVisible];
    
        return YES;
    }
    

    Either way should work.