Is there a possible way to autorotate the device orientation to portrait when the current orientation of the device is faceup or facedown?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
You can disable or enable rotation of the screen in portrait mode by set an appropriate value in the project settings (Targets -> General -> Deployment Info section).
or
You can use this trick to make the system refresh your controller orientation anytime you want:
This will call
supportedInterfaceOrientations
on your controller.Just return
UIInterfaceOrientationMaskPortrait
when the device orientation is facing up or down and your controller's view will get adjusted accordingly.Observe
UIDeviceOrientationDidChangeNotification
s to use the trick when you receive the notification and it's a face up/down device orientation, as those orientation do not correspond toUIInterfaceOrientation
s (and won't triggersupportedInterfaceOrientations
).Device and interface orientation definitions:
Use this code in your - (void)viewWillApper method
You don't change the orientation. Instead, you tell iOS which orientations you support, so when the user rotates the device, iOS will switch the UI orientation to one that your application supports. The UI orientation should only change when the user rotates the device.