1

I have a split view app running fine on the iPad. It is using the default setup (Popover in Portrait, table view on the left in landscape). The views shift correctly once the app is running. The problem I am seeing is that when the app starts (in the simulator) running in landscape mode the UI paradigm is the one intended for Portrait mode (Master List is a popover) is what loads.

I am thinking this is some strangeness with the simulator, or I am missing an option on my main view controller.

0

4 Answers 4

2

I ran into the same problem as is described here. The solution was, embarrassingly, as simple as manually setting the view's frame before adding it to the window.

Just check the interface orientation and, if it's landscape, switch the application frame width and height dimensions (i.e., width becomes height, height becomes width).

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;
}
1
  • I do not see this as embarrassing to you the developer; it is a deficiency in the SDK. There is no way this step should be required. Were you not using a Split View Controller in your app you would not have to take this step. Jun 22, 2010 at 12:07
0

Adding this as an answer as well in the hopes it will be more apparent to those in need of the same fix.

I solved this. I was waiting for an external XML stream to be loaded & parsed. As a result I was loading the window with the splitViewController view AFTER my applicationDidFinishLaunching method.

Adding:

[window addSubview: splitViewController.view]; 
[window makeKeyAndVisible]; 

back into that method fixed the orientation recognition

0

I succeeded into displaying a loading view by doing

[window addSubview:self._splitViewController.view];
[window addSubview:self._myLoadingView];
self._splitViewController.view.hidden = YES;
[window makeKeyAndVisible];
[self loadAllDatas];
self._splitViewController.view.hidden = NO;

i works fine

1
  • Does this work for you if you have a view that is NOT part of the SplitViewController loaded? Part of the issue is that I wanted to have a "loading" view appear. When I did this it threw everything off, including the orientation support doing things the way you outlined above. Jul 8, 2010 at 11:57
0

It doesn't work correctly because the default detail view controller of UISplitViewController is just a plain UIViewController. The shouldRotate method of UIViewController returns YES for portrait mode only.

Adding a generic UIViewController returning YES in shouldRotate for all orientations solved the problem for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.