zoukankan      html  css  js  c++  java
  • 自動旋轉和自動調整大小

    一、           自動旋轉和自動調整大小

    1.      創建一個名為AutoSize項目後,單擊AutoSizeViewController.m,可看到模板已提供了一個名為shouldAutorotateToInterfaceOrientation的方法。

    2.      系統通過調用此方法詢問視圖控制器是否旋轉到指定方向。

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {

        return (interfaceOrientation == UIInterfaceOrientationPortrait);

    }

     

    3.      interfaceOrientation參數將包含以下四個值之一,並且 此方法需要返回YESNO,以指示是否應該旋轉應用程序的窗口以匹配新的方向。由於每個視圖控制器子類實現此方法的方式各不相同,因此一個應用程序可能僅支持旋轉部分視圖,而不支持旋轉其它視圖。

    UIInterfaceOrientationPortrait

    UIInterfaceOrientationPortraitUpsideDown

    UIInterfaceOrientationLandscapeLeftUIInterfaceOrientationLandscapeRight

    4.      若要啟動自動旋轉,只需將方法更改為對傳入的任何值都返回YES。如

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {

        return YES;

    }

    5.      若只想支持其中的一部分方向,則必須檢查interfaceOrientation的值,對想要支持的值返回YES,對不想支持的值返回NO。例如要支持兩個方向中的縱向模式和橫向模式,但不支持旋轉到倒置的縱向模式,代碼如:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {

        return (interfaceOrientation == UIInterfaceOrientationPortrait ||

                            interfaceOrientation==UIInterfaceOrientationLandscapeLeft ||

                            interfaceOrientation==UIInterfaceOrientationLandscapeRight );

    }

  • 相关阅读:
    Linux sort -n 与 -g 排序对比
    shell中IF的用法介绍
    Firewalld 用法解析
    Centos7最小化安装后再安装图形界面
    PXE无人值守部署centos7.4操作系统
    kali之获取靶机的图片和看的url
    Kali的源得数字验证问题
    kali之Nmap (Network Mapper(网络映射器)
    kali之EtterCap学习
    Kali linux查看局域网内其他用户的输入信息
  • 原文地址:https://www.cnblogs.com/Snowfun/p/1970988.html
Copyright © 2011-2022 走看看