Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch iPhone App in iPad with landscape mode

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;
}
like image 664
lu yuan Avatar asked Feb 26 '13 14:02

lu yuan


People also ask

How do I make my iPhone Apps landscape on iPad?

Answer: A: For compatible Apps that are intended for iPhone, iPadOS15 will now automatically rotate the App to display in Landscape screen orientation. There is no manual configuration or setting to enable this feature.

How do I force an app to open in landscape mode?

Setting the app upWhen on the main screen, under the orientation section, you will see a number of options like 'Auto-rotate OFF', 'Auto-rotate ON', 'Forced Portrait' and 'Forced Landscape'. As the names suggest, you can use these buttons as one-tap shortcuts to toggle the orientation of your device.

How do I make my iPhone Apps landscape?

Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off.

Can you force apps to rotate on iPhone?

iOS Settings and (lack of) Apps To find the setting in iOS 11, you will need to swipe up from the bottom of the screen and open the Control Center. Locate the Rotation Lock icon that looks like a lock, with an arrow circling it in a clockwise direction.


1 Answers

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.

like image 169
sergio Avatar answered Oct 05 '22 23:10

sergio