Diagnose rotation problems on iPad - ios

I am having a weird problem with keeping orientation on the iPad. Very rarely, when I swap in and out view controllers, my view is displayed as portrait, even though my device is in landscape mode.
What should I do to resolve this problem? I have already set my controllers to landscape using shouldAutorotateToInterfaceOrientation: method. Also, it appears only very rarely, making tracking the bug very difficult.
Is there a faster way to find out why the orientation is wrong, besides going through each controller?

I see your comment that you are managing orientation by code using "shouldAutorotateToInterfaceOrientation", that is specifically an iOS5 method. By any chance is the iPad iOS6? If it is, you need to back it up with "supportedInterfaceOrientations".

Related

Has anyone been able to override/block the new iPadOS 15 behavior of rotating iPhone apps in landscape?

The new behavior
Ideally we'd have native iPad support, but that's a ways off and not feasible at the moment. So for now we have to work with iPad running the iPhone app. Hybrid Swift and Objective-C using UIKit, for context.
The app I'm working on has a camera view controller that, prior to iPadOS 15, would not rotate the field of view between portrait and landscape. However, with this new rotation behavior, the UI is shown in portrait when the iPad is in landscape. In the case of the camera, the field of view is now flipped 90ยบ. The captured images are not flipped, but the sideways field of view isn't a good look.
What I've tried/observed so far is the following:
This new rotation behavior is not governed by the UIViewController's rotation methods. Overriding shouldAutorotate and supportedInterfaceOrientations does not prevent this rotation. So this is happening at the device level, and not the view controller level.
At the device level, I only know of one way to programmatically change orientation, using the private setter on UIDevice's orientation property. Obviously, private APIs are a no-no for the App Store, and a hack to leverage them may break in the future. Not a good solution either.
At this point I'm at the end of my rope. I have scoured Google and StackOverflow to learn more about how this new feature works, at a technical level, but details are sparse. If anyone has more information or experience with this, that would be great. Even if the answer is 'no dice'. Thanks!

Force Rotate iOS Even When Device's Portrait Orientation Lock is ON

My app needs to somehow mimic the iOS original Camera App, that even the device's AUTOROTATE is locked, the ViewController or specifically the AVCaptureVideoPreviewLayer will rotate.
So far, what I did to my project is this: Check the Landscape (right and left) in Project Properties/Settings, and then tweak each View Controllers' shouldAutorotate.
Everything is fine using this technique, until the user lock his device autorotate function (in iPAD this is a button at the side of the device, in iPhone this can be found in the settings from below the screen).
I couldn't find any answered related question on stackoverflow, so I asked.
So after few days, I have solved the problem!!! I'm still wondering though what was the reason behind in down voting my question. I have found this tutorial/blog:
Detect Device Rotation Even When Rotation Lock Is ON
So basically, the alternative way is to use CoreMotion. I hope someone who is having the same question in mind finds this answer. Cheers!

UISplitViewController - Use as slideout-style menu

I'm struggling a bit with the new UISplitViewController in iOS 8.
I want to achieve a slideout-style menu on iPhone (landscape and portrait) as well as on iPad in portrait orientation and a persistent sidebar on iPad in landscape orientation.
I got a UITableViewController as the master and a UINavigationController with a couple of UIViewControllers as the detail in my SplitViewController.
Is it possible to to get something like this with the new UISplitViewController in iOS 8?
First it would be enough the get the iphone sliding thing to run :D
Thank you :)
The UISplitViewController will do just that. Sliding menus and everything.
It works like a dream if you use it exactly by the book. And this requires setup of some UINavigationControllers as part of the magic.
Tutorial is highly recommended for the first time. It's easy to get it messed up quickly otherwise. :)
http://nshipster.com/uisplitviewcontroller/
By default, the UISplitViewController in iOS8 will only act as a slideout-style menu on the iPad (in both portrait and landscape mode) and iPhone 6+ (in landscape mode only).
As to whether or not it is possible to get the slideout-style menu working on all iphones via the splitViewController, I don't actually know (I'm still new to iOS development). I suspect that it entails modifying how the splitViewController treats different size classes. If there isn't an easy way to change the splitViewController's behavior, perhaps you could subclass the splitViewController and override the functionality that you do not like.
I have not tried this before, nor do I actually know how the controller determines how it is displayed in different size classes. However, if I were trying to accomplish what you are, then this is what I would be looking up.

Status bar and UI orientation didn't match

I have a problem in iOS. It's support all interface orientations. But when orientation-locked modal controller is presented (by calling [self presentViewController:UIViewController animated:YES completion:nil]), sometimes the UI orientation is messed up.
Here are the steps:
Orientate the device so it's in portrait mode (doesn't matter portrait or upsideDown).
Present view controller as modal controller. This controller only support landscape mode. The UI orientation obviously rotated to landscape. Keep the device in portrait (since the controller is forced to landscape, the UI will still show a landscape UI eventhough the device is in portrait).
Dismiss the modal controller. Now the main UI is in landscape mode. The problem is, this main UI is supporting all orientations (like stated above).
After doing some interaction (without changing the device orientation), the device orientation suddenly back to portrait, but the UI does not follow suit.
Here's how the final screenshot:
My current thought is that this is iOS bug. I want to look for another opinions regarding this bug. I've search around the net (bing and google) and found nothing.
I often saw this in apps, sometimes even in iOS itself (on homescreen etc)..
I think it's an iOS bug and we as developers can nothing do about it, just write bug reports.

Landscape orientation for iPad?

Frustrated by how simple this should be...
I'm trying to add landscape support to an existing iPad app of mine. Do I actually have to create a completely new view controller for landscape mode? (surely not as that is a complete pain!)? Or can I use the existing view controllers and design for landscape and portrait? The simulated metrics thing doesn't work because whenever I make changes in a view controller in landscape mode and switch back to portrait it messes everything up! I know how to switch the view to landscape programmatically, this is (at least i think) an 'interface builder' sort of issue.
Why is this so difficult to do/hard to find!? Might be worth mentioning I'm using Xcode 4.2 with storyboards rather than separate xibs. Surely I don't have to use a separate view and segues because I really can't be bothered wasting my time with that.
Any help would be nice! Thanks
Watch for -willRotateToInterfaceOrientation:duration: and change the frame of your interface elements when the rotation changes.

Resources