iPad split view loading strangely
So I have a simple split view that functions great except when the view loads. For some reason if it loads in landscape mode, it only loads on ~half the screen (it开发者_JS百科 seems like it is the width of the portrait mode). Does anyone know what may be causing this behavior? I am using the default split view controller provided by the apple SDK.
That is an image of what I am talking about. I am not doing anything special in my view did load and things are wired up in IB properly. I am kind of at a loss and any help would be awesome. Thanks!
Figured it out:
I was loading the view after displaying a loading screen. As a result it wasn't detecting the orientation properly. I added this manual check before adding the view to the window and it solved my problems.
CGRect frame = [[UIScreen mainScreen] applicationFrame];
switch(controller.interfaceOrientation){
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
[controller.view setFrame:frame];
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
[controller.view setFrame:CGRectMake(frame.origin.x, frame.origin.y, frame.size.height, frame.size.width)];
break;
}
精彩评论