Git Product home page Git Product logo

rotatedemo's Introduction

RotateDemo

  • 该demo以常见的TabbarController---NavController ---Controller控制器结构为例。
1. 项目工程勾选支持的屏幕方向

image

2. tabbar

 shouldAutorotate  supportedInterfaceOrientations调用顺序最底层容器控制器有优先权级别,先判断tabbarController,再判断navgationController,在具体的某个contoller
-(BOOL)shouldAutorotate
{
    if ([self.selectedViewController isEqual:[self.viewControllers objectAtIndex:0]]) {
         return [self.selectedViewController shouldAutorotate];
    }
    return NO; // tabbar第一栏旋转控制交给下级控制器,其他栏不支持自动旋转
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    if ([self.selectedViewController isEqual:[self.viewControllers objectAtIndex:0]]) {
        return [self.selectedViewController supportedInterfaceOrientations];
    }
    return UIInterfaceOrientationMaskPortrait; // tabbar第一栏控制器所支持旋转方向交给下级控制器处理,其他栏只支持竖屏方向
}

####3. nav

- (BOOL)shouldAutorotate
{
    if ([self.topViewController isKindOfClass:[RotateAblePushController class]]) {
        return [self.topViewController shouldAutorotate];
    }
    return NO; // RotateAblePushController自动旋转交给改控制器自己控制,其他控制器则不支撑自动旋转
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    if ([self.topViewController isKindOfClass:[RotateAblePushController class]]) {
        return [self.topViewController supportedInterfaceOrientations];
    } else {
        return UIInterfaceOrientationMaskPortrait; // RotateAblePushController所支持旋转交给改控制器自己处理,其他控制器则只支持竖屏
    }
}

4. 具体某个需横屏的控制器

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    if (1) { // 旋转支持方向 ,可加条件旋转;比如我之前的项目是在视频流出现之后才支持横屏,否则只能竖屏
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
    return UIInterfaceOrientationMaskPortrait;
}

/**
 *  支持自动旋转
 */
- (BOOL)shouldAutorotate
{
    return  YES;
}

image image

rotatedemo's People

Contributors

jude309307972 avatar jkpang avatar

Watchers

James Cloos avatar 侯胤博 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.