iOS turn off the horizontal screen after a single page to toggle the screen

Source: Internet
Author: User

In the viewcontroller you want to support the screen, rewrite two methods:

// 支持设备自动旋转 - ( BOOL )shouldAutorotate {      return YES; } // 支持横竖屏显示 - (NSUInteger)supportedInterfaceOrientations {      return UIInterfaceOrientationMaskAll; }

In this viewcontroller, you can switch between the screen.


However, if your window's Rootviewcontroller is a navigationcontroller, the following issues may occur:

Navigationcontroller only support vertical screen, but you push to a new controller, this controller supports the horizontal screen, When you switch to a horizontal screen in a new controller (it is also possible to switch to a horizontal screen and then pop back), the program will blink because your navigationcontroller does not support horizontal screen.

This requires writing a uinavigationcontroller subclass, overriding the method in this class:

- ( BOOL )shouldAutorotate {      return [self.viewControllers.lastObject shouldAutorotate]; } - (NSUInteger)supportedInterfaceOrientations {      return [self.viewControllers.lastObject supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {      return [self.viewControllers.lastObject preferredInterfaceOrientationForPresentation]; }Then use this class to create an instance as the window's Rootviewcontroller, so you can avoid this problem.

iOS turn off the horizontal screen after a single page to toggle the screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.