Force portrait orientation programmatically
Force portrait orientation programmatically
- Subject: Force portrait orientation programmatically
- From: Devarshi Kulshreshtha <email@hidden>
- Date: Wed, 18 Apr 2018 11:09:05 +0530
In our app we are supporting both orientations, however on selection of one
option we have to force user to remain only in portrait mode on all the
screens until he toggles it. So far we have found only this workable
solution:
[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeLeft)
forKey:@"orientation"];
[UINavigationController attemptRotationToDeviceOrientation];
Reference link: https://stackoverflow.com/a/26358192
The other solution which we tried is - returning NO from -shouldAutorotate
delegate. However the problem with this approach is that the delegate is
only called on currently displayed view controller not on previous view
controllers which might be behind it on navigation stack (or is presenting
view controller), hence only currently visible view controller starts
appearing in portrait mode, while previously displayed remain in landscape
mode.
I have two questions now:
Q1: Can our app be rejected from app store if we use the workable solution,
since we are trying to use the 'internal thing'?
Q2: What is the best approach to force set the orientation in app, at
runtime, say on tap of a button?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden