Search code examples
iosuiviewuisplitviewcontrollerios6xcode4.5

View drops 20 pixels when build against iOS 6 SDK in Xcode 4.5


After building my iPad app against iOS 6.0 SDK, I get this weird behavior with my UISplitViewController's detailed view. The detailed view is positioned 20 pixels (points / 40 pixels) lower than it should be.

enter image description here

Here is what it looked like under 5.1:

enter image description here

For DetailViewController_iPad.xib in Interface Builder I've set the Simulated Metrics > Top Bar to None. This didn't help. I've logged the view frame:

- (void) viewDidLayoutSubviews {
//.. etc
NSLog(@"viewDidLayoutSubviews: %@", CGRectCreateDictionaryRepresentation(self.view.frame) );
}

This logs the height as 684 instead of the what it should be: 704.

Height = 684; Width = 703; X = 0; Y = 0;

Anyone have any experience with this sort of thing? What should I try next?

UPDATE: This problem seems intermittent, with some compiles causing it, and some not.

If anyone else has had this problem and found out what causes it, I'd still be keen to know.


Solution

  • I had the exact same issue!

    The issue will occur when there is another view controller in the navigation controller and this split view controller is pushed in the method application:didFinishLaunchingWithOptions: during app launch.

    This fixed the problem for me:

    When pushing the splitViewController I used

    dispatch_async(dispatch_get_main_queue(), ^{
    
         [self.navigationController pushViewController:splitViewController animated:NO];
    
    })
    

    instead of

    [self.navigationController pushViewController:splitViewController animated:NO];
    

    I used this only for iOS6 otherwise first view will be momentarily showed in OS < iOS6.