zoukankan      html  css  js  c++  java
  • IOS7适配

    (1)如果应用程序始终隐藏 status bar 那么恭喜呢,你在UI上需要的改动很少很少。

    (2)如果应用程序显示status bar,可以讲status bar设置成黑色不透明 ,然后在UIViewController 中加入下面的判断,

    #define IOS7_OR_LATER ( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )

    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ( IOS7_OR_LATER )
    {
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = NO;
    self.modalPresentationCapturesStatusBarAppearance = NO;
    }
    #endif // #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000

    (3)如果勾选了Hide during application lauch 的话,在IOS7 的设备上,是没有问题的,

       启动完以后status bar 会重新出现的,但是在IOS7 一下的设备,需要在launch didfinish 里面把status bar 显示出来。

    (4)可以通过设置view的背景颜色来改变 status bar 的颜色来搭配你的nav 条。

       (5)  有些地方肯能要对版本进行判断,分别做不同的处理。

       (6)  可以用旧版的sdk来编译,这样在真机上还是和原来一样的效果。具体的方法可以参考:http://github.kimziv.com/blog/2013/09/22/how-to-use-older-base-sdks-in-xcode5/

    在iOS 8中,[UIScreen bounds] 、[UIScreen applicationFrame] 、Status bar、Keyboard这些frame都是根据设备真实方向来返回frame的,而在iOS 7中,不过是横屏还是竖屏,iOS总是返回竖屏的frame,如以下输出:

    iOS 7:

    1. 竖屏:  
    2. UIScreen.mainScreen().bounds: (0.0,0.0,320.0,568.0)  
    3. 横屏:  
    4. UIScreen.mainScreen().bounds: (0.0,0.0,320.0,568.0)  

    iOS 8:

    1. 竖屏:  
    2. UIScreen.mainScreen().bounds: (0.0,0.0,320.0,568.0)  
    3. 横屏:  
    4. UIScreen.mainScreen().bounds: (0.0,0.0,568.0,320.0)  

    这就对某些支持横屏的App造成了困扰,其实也只需要加两个宏或者改造一下就行了:

    1. #define SCREEN_WIDTH        (getScreenSize().width)  
    2. #define SCREEN_HEIGHT       (getScreenSize().height)  
    1. CGSize getScreenSize() {  
    2.     CGSize screenSize = [UIScreen mainScreen].bounds.size;  
    3.     if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) &&  
    4.         UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {  
    5.         return CGSizeMake(screenSize.height, screenSize.width);  
    6.     }  
    7.     return screenSize;  
    8. }  

    虽然 contentInset 不属于屏幕适配的内容,但是我还是放在屏幕适配里说一下。iOS8 和 iOS7 对 automaticallyAdjustsScrollViewInsets 属性的解释不一样:

    • iOS8 会把该属性的影响作用到 controller 的 view 的 subviews 上
    • iOS7 仅会作用到 self.view 上
    另外当你还需要手动调用 contentInset 的时候,iOS7 似乎就不会自动调整了。解决办法就是将 automaticallyAdjustsScrollViewInsets 设置为 NO,然后自己控制 contentInset
    引用地址
    http://www.cocoachina.com/bbs/read.php?tid=274004 
  • 相关阅读:
    [ACM训练] 数据结构----树、二叉树----c++ && python
    [机器学习] ——KNN K-最邻近算法
    [Python学习] Linux环境下的Python配置,必备库的安装配置
    [Python学习] python 科学计算库NumPy—矩阵运算
    [Python学习] python 科学计算库NumPy—tile函数
    [机器学习] ——初识及实践选择
    [机器学习] 虚拟机VMware中使用Ubuntu的联网问题
    使用ScribeFire,Windows Live Writer 2012和Office Word 2013 发布文章到博客园全面总结
    工作常用 随笔记录
    JavaScript取子串方法slice,substr,substring对比表
  • 原文地址:https://www.cnblogs.com/wcLT/p/4735693.html
Copyright © 2011-2022 走看看