IOS9 Horizontal Screen Vertical screen setting

Source: Internet
Author: User

公司App里面有个需求,即所有界面都是竖屏,且不允许横屏切换,唯独有一个播放视频的界面允许横屏,大家都知道视频播放适配最大的播放屏幕那样是最好的。从网上多方查找资料,查到了这么一篇文章:
    1. Ultimately, this needs to be handled as follows: first, make sure that the app itself should allow the switch to be turned on:

    2. The Uitabbarcontroller in my app is the root view controller, so first create a Uitabbarcontroller subclass and set the Allow to turn screen:
      (These are placed in the root view controller, if your app root view is Uinavigationcontroller, just put it in there.)

#pragma mark 转屏方法重写-(UIInterfaceOrientationMask)supportedInterfaceOrientations{    return [self.viewControllers.firstObject supportedInterfaceOrientations];}-(BOOL)shouldAutorotate{    returnself.viewControllers.firstObject.shouldAutorotate;}
    1. Then, in my Tabbarcontroller, each sub-controller is uinavigationcontroller for the interface push switch, so first create a uinavigationcontroller subclass, and set the Allow to turn the screen:
//self.topViewController是当前导航显示的UIViewController,这样就可以控制每个UIViewController所支持的方向啦!-(BOOL)shouldAutorotate{    return [self.topViewController shouldAutorotate];}- (UIInterfaceOrientationMask)supportedInterfaceOrientations {    return [self.topViewController supportedInterfaceOrientations];}
    1. In the viewcontroller you want to switch the screen can be rewritten as such (allow left and right horizontal screen and vertical screen):
- (BOOL)shouldAutorotate {    return NO;}- (UIInterfaceOrientationMask)supportedInterfaceOrientations {    return UIInterfaceOrientationMaskPortrait;}
    1. To the video playback interface to be set to horizontal screen (my video playback as long as the horizontal screen is good ^_^)
// 是否支持屏幕旋转- (BOOL)shouldAutorotate {    returnNO;}- (UIInterfaceOrientationMask)supportedInterfaceOrientations {    return UIInterfaceOrientationMaskLandscape;}-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {    return UIInterfaceOrientationLandscapeRight;}

Note: Jump to the player to use the modal, with push will error
[Self PRESENTVIEWCONTROLLER:PLAYERVC animated:yes completion:nil];

IOS9 Horizontal Screen Vertical screen setting

Related Article

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.