• shouldAutorotateToInterfaceOrientation


    关于屏幕旋转的问题:

    iOS6之后

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
           return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
    }

    这个方法废弃啦,取而代之的是这俩个组合:
    - (BOOL)shouldAutorotate
    {
       return YES; //ios6之前默认为NO,ios6之后默认为YES
    }
     
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscape;
    }

    当然,为了保持对旧版本系统行为的兼容性,不要删掉shouldAutorotateToInterfaceOrientation方法。另外还有一个preferred朝向也可以加上,这个大概说的是横屏的时候屏幕的方向
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationLandscapeRight;

    }

    简单说明:

    UIInterfaceOrientationMaskLandscape  支持左右横屏
    UIInterfaceOrientationMaskAll  支持四个方向旋转
    UIInterfaceOrientationMaskAllButUpsideDown 支持除了UpsideDown(home键在上)以外的旋转

    另外:

    1.info.plist文件里 Supported interface orientations里面的值表示支持的旋转方向,可以添加也可以删除,iphone默认为三个方向(除了home键在上),ipad默认为四个方向,

    2.旋转后如需重新绘图,有以下两种方法:

    (1)在该view的属性视图中设置mode为Redraw

    (2)在view里实现以下代码:

    - (void)setUp //随便其他的方法名称也可以

    {

        self.contentMode = UIViewContentModeRedraw; //设置为需要重新绘图

    }

     

    - (void)awakeFromNib //这种情况是当前view被移除后再次唤醒的时候调用

    {

        [self setUp];

    }

     

    - (id)initWithFrame:(CGRect)frame //这种情况是第一次使用当前view的时候调用,view被移除后再次使用不会调用此方法,而是调用awakeFromNib

    {

        self = [super initWithFrame:frame];

        if (self) {

            [self setUp];

        }

        return self;

    }

  • 相关阅读:
    进程通信
    Python爬虫获取随机的UserAgent的两种方法
    Chrome插件【请停用以开发者模式运行的扩展程序】的提示解决方案
    FCFS,SJF,HRRN调度算法总结分析(全)
    进程控制
    进程的状态和转换
    进程的调用
    系统调用
    终端和异常
    今日份崩溃——时刻注意细节
  • 原文地址:https://www.cnblogs.com/shadowflyer/p/3488415.html
Copyright © 2020-2023  润新知