Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 375
MattyG Avatar asked Sep 25 '12 10:09

MattyG


4 Answers

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.

like image 155
8suhas Avatar answered Nov 10 '22 09:11

8suhas


I'm assuming you're not doing anything to effect the frame of the view in code, correct? It's the view's controller that's doing all the layout? If so, have you tried tinkering with -wantsFullScreenLayout?

When a view controller presents its view, it normally shrinks that view so that its frame does not overlap the device’s status bar. Setting this property to YES causes the view controller to size its view so that it fills the entire screen, including the area under the status bar. (Of course, for this to happen, the window hosting the view controller must itself be sized to fill the entire screen, including the area underneath the status bar.) You would typically set this property to YES in cases where you have a translucent status bar and want your view’s content to be visible behind that view.

If this property is YES, the view is not resized in a way that would cause it to underlap a tab bar but is resized to underlap translucent toolbars. Regardless of the value of this property, navigation controllers always allow views to underlap translucent navigation bars.

The default value of this property is NO, which causes the view to be laid out so it does not underlap the status bar.

Mind you, -wantsFullScreenLayout should really only effect a window's root view controller. So if this fixes your problem (and you're not doing anything goofy with your view controller hierarchy), please file a bug with Apple!

like image 37
jemmons Avatar answered Nov 10 '22 08:11

jemmons


Maybe [UIViewController statusBarHidden] is set to NO on your detail controller?

like image 40
Sulthan Avatar answered Nov 10 '22 09:11

Sulthan


Xcode 4.5 has a habit of applying autolayout, which may be the cause of some of your grief - inspect this and trying deselecting it.

like image 39
Mitchell Currie Avatar answered Nov 10 '22 07:11

Mitchell Currie