zoukankan      html  css  js  c++  java
  • 屏幕旋转

    第一步

    AppDelegate.h 里增加一个属性

    @property (nonatomic, assign) NSInteger allowRotation;
    

    用来区分哪个界面可以横屏

    哪个界面不可以

    第二步

    AppDelegate.m 里增加一个方法

    -(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        if(self.allowRotation==1)
        {
            return UIInterfaceOrientationMaskAll;
        }
        else
        {
            return UIInterfaceOrientationMaskPortrait;
        }
    }
    

    第三步

    在需要横屏的界面调用以下代码即可

        AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
        appDelegate.allowRotation = 1;
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortrait] forKey:@"orientation"];
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIDeviceOrientationLandscapeRight] forKey:@"orientation"];
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortraitUpsideDown] forKey:@"orientation"];
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
    
    

    Demo地址:https://github.com/YouZhiZheShiJingCheng/revolve/tree/master

  • 相关阅读:
    mongodb安装与启动
    js数组操作
    js字符串操作
    js原型对象和原型链
    Js 原型对象与原型链
    zepto
    闭包的理解
    JSON与XML的区别比较
    ajax 异步请求四个步骤
    angularJS之项目知识
  • 原文地址:https://www.cnblogs.com/BK-12345/p/13216522.html
Copyright © 2011-2022 走看看