zoukankan      html  css  js  c++  java
  • 关于iOS中支持屏幕取向的讲解

    可以通过设置 VC对应的 XIB 中 View 的show attrubite inspector属性,更改其 Orientation为 Landscape,即可默认为横屏布局。
    我们可以通过3种方式设置 App界面的取向。

    第一种:通过全局设置
    // The system only calls this method if the application delegate has not
    // implemented the delegate equivalent. It returns the orientations specified by
    // the application's info.plist. If no supported interface orientations were
    // specified it will return UIInterfaceOrientationMaskAll on an iPad and
    // UIInterfaceOrientationMaskAllButUpsideDown on a phone.  The return value
    // should be one of the UIInterfaceOrientationMask values which indicates the
    // orientations supported by this application.
    - (NSUInteger)supportedInterfaceOrientationsForWindow:(UIWindow *)window NS_AVAILABLE_IOS(6_0);

    第2种,通过Deployment Info下的 Device Orientation 中选择取向,当然这里和 Plist 文件里Supported interface orientations对应的取向一致,改变一个地方另一个地方也会随之改变。

    第3种,单一的设置 VC 做支持的取向。通过函数(iOS 6.0以后)
    - (BOOL)shouldAutorotate{
    return YES;
    }

    - (NSUInteger)supportedInterfaceOrientations{
       return UIInterfaceOrientationMaskLandscape;
    }
    可以设置当前 VC 所支持的方向。

    最终视图所支持的取向由这3个的交集决定。需要注意的是Plist 文件里所支持的方向,会按照第一项来执行。(若支持)

    参考资料:http://www.tuicool.com/articles/e2q6zi, 
    图片:横屏布局.png 
  • 相关阅读:
    Android
    Android
    Android
    Android
    Android
    Android
    Android
    Android
    Android
    Android
  • 原文地址:https://www.cnblogs.com/iOS-kk/p/5207515.html
Copyright © 2011-2022 走看看