iOS: How do I maintain my orientation when resuming the app from the multitask bar?
Issue:
If I send the app to the background when in UIInterfaceOrientationLandscapeRight orientation, when I resume the application from the multi-taskbar the orientation is UIInterfaceOrientationLandscapeLeft which is the default, for both the snapshot and view displayed. The view immediately re-orients itself by rotating back to the last known orientation before being suspended, UIInterfaceOrientationLandscapeRight.
Known Quantities:
- App supports 2 InterfaceOrientations: UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight
- App utilizes auto-rotation all view controllers overriding ShouldAutoRotateToInterfaceOrientation, returning yes if the orientation is either of those supported
- Both orientations are defined within the Info.plist under the UISupportedInterfaceOrientations key
- When the app is sent to the background the automatic snapshot is taken and stored for the supported orientations
- Resuming the app from the springboard works as expected, the orientation is the same as when it was sent to the backg开发者_运维问答round.
Observed Behavior:
When resuming the app from the multi-taskbar, the app receives 2 orientation notifications which are respectively evaluated by the overridden shouldAutoRotateToInterfaceOrientation. First UIInterfaceOrientationLandscapeLeft, then UIInterfaceOrientationLandscapeRight.
Expected Results:
When resuming the app from the multi-taskbar, the orientation is the same as when it was suspended. So if we were in the UIInterfaceOrientationLandscapeRight mode, then I'd expect to resume with the same orientation.
I know this is an old post, but the answer is that you are not defining the key UISupportedInterfaceOrientations
in your Info.plist file with the values UIInterfaceOrientationLandscapeLeft
and UIInterfaceOrientationLandscapeRight
.
精彩评论