I have a rotation (orientation change) issue in an iOS app. The app has several view controllers to navigate.
I want it to be possible to rotate except for iPhone 4 (3.5 inches devices). On a 3.5 inches device it shoulld always stay in portrait mode.
I am able to prevent direct rotation, that is when inside a view controller, if the user holds the device in portrait mode an them in landscape mode nothing happens. This is exactly what I want.
Problems happen when changing view controller while holding in landscape mode. In this case the new view controller shows up in landscape mode, and I don't want that.
I tried to use
- (BOOL)shouldAutorotate;
returning NO when the device is 3.5 inches but that does not work.
How can I prevent this behavior?
I may need to add one detail: the 3.5 inches device I am using to test runs iOS version 9.3.5.
I am using Xcode 9.4.1.
You can use the method supportedInterfaceOrientations.
For example:
Objective c
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
//return your preferred orientation
return UIInterfaceOrientationMaskPortrait;
}