UIViewController in UIPopoverController always reports as being in Portrait mode - ios

I've got a view controller in a UIPopoverController. I want to adjust the ui based on whether or not it is in portrait orientation.
No matter what orientation my iPad is in (physical device), self.interfaceOrientation always reports Portrait. I'm logging it in -viewWillAppear: and it's always Portrait.
Why?

Use:
UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;
to recognize statusBar oriantation.

A view controller in a popover is always in portrait. The popover's orientation is always portrait no matter which way the device is held.
If you wish to do something different in the view controller based on the device's orientation, look at the UIApplication statusBarOrientation.
Think of the popover as following gravity. It always points down.

Related

Present one view in landscape mode in an otherwise portrait mode app

I have an application (iPhone only) that is portrait-only, but with one exception, a view that must be displayed in landscape mode.
I have implemented the technique described in the accepted answer in How to lock orientation of one view controller to portrait mode only in Swift, albeit in Objective-C.
Since I've overridden the -lockOrientation methods in -viewWillAppear and -viewWillDisappear of the landscape view controller, I don't undertand why I see rotation occur after the view appears; I would have thought that would occur before the view appears.
When my presented landscape view is overlaid by a presented portrait view, the portrait view starts out as landscape (because it's presented over a landscape view before rotation), but the rotated view has only the height it had in landscape mode.
When the portrait view is dismissed, the first, landscape view has now rotated to portrait mode, even though I've also implemented -supportedInterfaceOrientations and -preferredInterfaceOrientationForPresentation for landscape mode. This has been noted in UIViewController orientations, but there didn't appear to be any working solutions posted there.
Both view controllers, the landscape and the portrait that overlays it, are presented rather than pushed.
Also, the only flag set in the project's Info.plist is Portrait. The full-screen flag is not set.
In short, it's a hot mess just trying to make one exception to view orientation in my app.
Any clues to solving the behavior I've described would be greatly appreciated.

UIModalPresentationFormSheet wrong orientation on iPad in landscape

I have UIViewController presented using UIModalPresentationFormSheet style. Also my app support only landscape orientation. Then I try to use frames or animations in that controller and have strange effect, like my presented controller is in UIInterfaceOrientationPortrait but transformed on 90 degree. All methods (supportedInterfaceOrientations, preferredInterfaceOrientationForPresentation) have landscape only orientation in all controllers.

iOS trigger orientation change event

I have 2 UIViews. The first supports only portrait. The second both portrait and landscape. To achieve that i change the return value of supportedInterfaceOrientations so that it gives the right orientations depending on what view i am.
When i change from screen 2 to screen 1 the view remains in a buggy landscape form, however when i rotate the device the View actually rotates to portrait and is locked there correctly. The reason for that is that when i rotate the device a rotation change event will be triggered.
my question: Is there a way to programmatically trigger a orientation change event?
I believe what you're looking for is preferredInterfaceOrientationForPresentation on view 1:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}

Rotate UIView programmatically

I have UIViewController which supports only Portrait orientation.
In this viewController i have MPMoviePlayerController object. By default the movie controller supports both landscape and portrait orientations.
When it is in full screen mode and turned into landscape orientation the main view controller also changes his orientation, after exiting the full screen mode , the main view does not changes his orientation.
If I turn the device to portrait orientation, the main view automatically returns to the right orientation. The problem is that i dont want to rotate the main view even if the device is in landscape orientation.
Is there any way to prevent the main view to change its orientation when the movie controller rotates in full screen mode? or what is the right way to return main view into Portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
must return NO is iOS 5 or
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
in iOS 6 in your ViewController.

How to prevent iPad Modal that contain UIWebView to rotate to portrait

I have application that is only landscape with no other orentation supported.
But when I open modal view (modal contains UIWebView ([printView setView:webView])) it rotates the device to portrait.
The content stays in landscape view only iPad orientation. I mean the statusbar is rotated like it's in portrait. So I want no rotation at all, just to stay in landscape.
I have solved the problem. Problem was in viewController that was programaticly created.
Solution is to create viewControler and in .m file force landscape orentation.

Resources