How to realize horizontal and Vertical screen setting by iOS
Editor to share with you how to achieve iOS horizontal and vertical screen settings, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Horizontal and vertical screen below iOS 6, rewrite the method in ViewController
-(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation {/ / system macro definition only horizontal screen return UIDeviceOrientationIsLandscape (toInterfaceOrientation); / / system macro definition only vertical screen return UIDeviceOrientationIsPortrait (toInterfaceOrientation); / / you can also implement vertical screen only, with the home key below return (toInterfaceOrientation = = UIDeviceOrientationPortrait); / / you can also implement vertical screen only with home key return above (toInterfaceOrientation = = UIDeviceOrientationPortraitUpsideDown) / / you can also implement vertical screen only on your own, with return button on the right (toInterfaceOrientation = = UIDeviceOrientationLandscapeLeft); / / you can also implement vertical screen only on your own, and home button is return on the left (toInterfaceOrientation = = UIDeviceOrientationLandscapeRight);}
IOS 6 or above, set in AppDelegate. After setting, you need to set the screen in Target "Summary" Support Interface Orientations. Failure to set the same screen will cause flicker.
# if _ _ IPHONE_OS_VERSION_MAX_ALLOWED > = _ IPHONE_6_0-(NSUInteger) application: (UIApplication *) application supportedInterfaceOrientationsForWindow: (UIWindow *) window {/ / horizontal screen home key below return UIInterfaceOrientationMaskPortrait; / / horizontal screen home key on the right return UIInterfaceOrientationMaskLandscapeLeft; / / horizontal screen home key on the left return UIInterfaceOrientationMaskLandscapeRight; / / vertical screen home key on top return UIInterfaceOrientationMaskPortraitUpsideDown; / / landscape screen return UIInterfaceOrientationMaskLandscape / / four-way flip return UIInterfaceOrientationMaskAll; / / except vertical screen, three-way flip return UIInterfaceOrientationMaskAllButUpsideDown;} # endif is all the contents of this article "how to achieve horizontal and vertical screen settings in iOS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!