iPhone landscape orientation mode issues - ios

I settings my info.plist as below:
Initial interface orientation: Landscape (left home button)
Supported interface orientations: Landscape (left home button) and Landscape (right home button)
When I started my app, the orientation device have landscape mode, but my view not rotate to this orienatation.
I use method below for rotate orientation, but view not initial in landscape mode (after I have rotate my device in this case I had needed result - view rotate in landscape mode)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

I've had a couple of issues with this in the past. Basically if you just put the initial view controller there it bugs out handling as if it was in portrait mode. The fix i found for this was adding the view controller to a navigation controller.
See this question i posted for the full explanation

Related

iOS autorotate is not working when you have different orientation screens

I am working on an App which is written in Objective-C. I have more screens and all screens are Landscape Left and Landscape Right orientations and these screens must not be in portrait mode. But I have got 3 different screens which should be in only Portrait mode must not be in Landscape Left or Landscape Right.
This is the code for Landscape mode for all screens-
And this is for Portrait mode for my app
These are all I did in my View Controllers and In app Plist I have added needed orientations like This Info.plist
And the app device orientation will automatically changes. like this -
.
I am pretty sure all is clear and should work as it is expected but for some reason when I use the app and lock the auto rotation and run the app it is automatically opening in Portrait mode and when I unlock the autorotation it will be in Landscape and you rotate it will be rotated to Portrait mode. I used shouldAutorate return YES because it should rotate it automatically between Landscape Left and Landscape Right so I used it also the portrait mode screen is opening in Portrait but it is autorotating when user rotates the device.
Any help would be appreciated, Please share any idea why my app is not working as expected.
Following are the steps to fix this issue:
Remove orientations from plist because it overrides whatever logic you have in your view controller.
Keep below code where you have landscape orientations:
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
For portrait mode use it as below:
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Now try locking the orientation your first view controller will appear in landscape and other one will be portrait regardless of orientation lock.

Landscape Orientation issue UIView and UIWindow in iOS 8

In my application, we support both portrait and landscape based the screens. when we push or navigate to portrait mode to landscape mode screen, then some portion of UIView doesn't has user interaction, popover controller view also presented in wrong orientation. This is weird issue ever i had. Please help me to get out of this complicated issue.

How to use UIInterfaceOrientationPortrait and UIInterfaceOrientationLandscapeLeft

I have a project whose rootViewController is a UINavigationController, and in my project only the view controller loading a full screen UIWebView. I need to change its orientation.
I have finished fixing the issue, but there's some trouble: When a user is in the view controller with the web view in the landscape orientation then clicks the back button, the previous view controller is also in landscape orientation. I want it to be in portrait, however. Any ideas on how to do this?
If you can read Chinese, I found this page, thanks.
implement
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
for whatever viewcontroller you require to stay in portrait.
I have try many solution, but the correct answer with working solution is:
ios 8 and 9, no need to edit info.plist.
- (BOOL) shouldAutorotate {
return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return (UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown);
}
possible orientation
UIInterfaceOrientationUnknown
The orientation of the device cannot be determined.
UIInterfaceOrientationPortrait
The device is in portrait mode, with the device held upright and the home button on the bottom.
UIInterfaceOrientationPortraitUpsideDown
The device is in portrait mode but upside down, with the device held upright and the home button at the top.
UIInterfaceOrientationLandscapeLeft
The device is in landscape mode, with the device held upright and the home button on the left side.
UIInterfaceOrientationLandscapeRight
The device is in landscape mode, with the device held upright and the home button on the right side.

iOS Orientation adapts to unapproved device orientation after Camera dismissed

I am currently writing an iOS app in which have the acceptable device orientations set to Landscape Right and Landscape Left, and in all of my view controllers, I’m returning only those two in the supportedInterfaceOrientations method.
However, if the user uses the in-app camera functionality (which is implemented via UIImagePickerController presented modally in full screen) and rotates the device to Portrait orientation to take a picture, the camera rotates to portrait mode (which is fine), and if the user clicks "Use Photo", when the modal view is dismissed, the view from which the camera was launched is somehow now in portrait mode (which is not fine).
After the camera view has been dismissed, the view controller from which it was launched has UIDeviceOrientationIsPortrait set to true. I am wondering how it ended up in this orientation, and how when a picture is taken, I can ensure that the presenting view controller remains in a landscape orientation. Any help is greatly appreciated!
I am currently writing an iOS app in which have the acceptable device
orientations set to Landscape Right and Landscape Left, and in all of
my view controllers, I’m returning only those two in the
supportedInterfaceOrientations method.
In iOS 6 and later, your app supports the interface orientations defined in your app’s Info.plist file
Have you tried setting it here? Then see if the problem still occurs.
Also, if this doesn't work, try setting the supportedInterfaceOrientations values in the viewWillAppear method of the ViewController that launched UIImagePicker?

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:
rootview-landscape:
What I expected look should be the same as the iPad is with portrait mode:
splash-portrait:
rootview-portrait:
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;
}
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.
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.
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.

Resources