5

In the project summary, "Supported Interface Orientations" are all selected, as there is a photo gallery view in my App, which can be rotated with device. The other views are portrait only. The target devices is iPhone, and all things perform well in the iPhone. But when it runs in my iPad with landscape mode, the splash and the rootView are as following:

splash-landscape: enter image description here

rootview-landscape: enter image description here

What I expected look should be the same as the iPad is with portrait mode:

splash-portrait: enter image description here

rootview-portrait: enter image description here

The rootView is MyNavigationController, some related code is as following:

MyNavigationController.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (NSUInteger)supportedInterfaceOrientations {
  return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotate {
  return NO;
}
lu yuan
  • 7,207
  • 9
  • 44
  • 78
  • I do not really understand what you are looking to do? How do you want the app to work with an iPad? – Mausimo Mar 07 '13 at 18:16

3 Answers3

9

Please, correct your code with the following:

- (BOOL)shouldAutorotate {
   return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
   return UIInterfaceOrientationMaskPortrait;
}

It may seem odd returning YES from shouldAutorotate. The fact is, if you do return NO, then supportedInterfaceOrientations will not be called at all and your project settings will rule. You could as well remove shouldAutorotate and it should work just the same.

Reference:

When the user changes the device orientation, the system calls this method on the root view controller or the topmost presented view controller that fills the window. If the view controller supports the new orientation, the window and view controller are rotated to the new orientation. This method is only called if the view controller’s shouldAutorotate method returns YES.

sergio
  • 68,819
  • 11
  • 102
  • 123
2

Do you mean by showing a landscape launch screen and then in app still use portrait mode?

As far I know, iPhone-only app can't launch in landscape mode, which means giving a landscape launch screen to iPhone-only app is useless.

Check the document here at the "Providing Device-Specific Launch Images" section.

CarmeloS
  • 7,868
  • 8
  • 56
  • 103
  • No. I know there the iPhone App do not support landscape launch image. What I want is when my iPhone App runs on an iPad with landscape mode, the perform the same as i run it on iPhone with landscape mode. – lu yuan Mar 01 '13 at 09:12
  • So you want your app's splash view to turn into landscape mode when ipad is in landscape mode? – CarmeloS Mar 01 '13 at 10:12
  • No. I wanna the app's splash view to be portrait. – lu yuan Mar 01 '13 at 10:15
  • this may be helpful http://stackoverflow.com/questions/5140600/fix-ipad-status-bar-orientation-as-portrait – CarmeloS Mar 01 '13 at 11:21
2

I guess what you want is make the status bar be portrait too. Unfortunately, there is no easy way to do this -- you can setup the device/interface orientation to protrait only, but it applies to the whole application. And you will need to process the orientation of all views by yourself. So, I will suggest you follow Hide status bar on launch image, hide your status bar, and use the same image in both orientations. It will make the splash screen look better.

Community
  • 1
  • 1
Chen-Hai Teng
  • 718
  • 6
  • 16