开发者

iPad split view loading strangely

开发者 https://www.devze.com 2023-01-17 06:10 出处:网络
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 wid

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.

iPad split view loading strangely

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消