• IOS7 适配以及向下兼容问题


    1.所有的UIViewController加如下方法。

        - (void) viewDidLayoutSubviews {
            if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){
                CGRect viewBounds = self.view.bounds;
                CGFloat topBarOffset = self.topLayoutGuide.length;
                viewBounds.origin.y = topBarOffset * -1;
                self.view.bounds = viewBounds;
                [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
            }
        }
    在项目的plist文件里加View controller-based status bar appearance,值为no
     
     
    2.scrollerView报错,找不到setAutomaticallyAdjustsScrollViewInsets:方法,解决方法
     
    重写方法setAutomaticallyAdjustsScrollViewInsets:

    - (void)setAutomaticallyAdjustsScrollViewInsets:(BOOL)automaticallyAdjustsScrollViewInsets

    {

        if(IS_IOS7){

            [super setAutomaticallyAdjustsScrollViewInsets:automaticallyAdjustsScrollViewInsets];

        }

    }

    然后viewDidLoad里面加上:
    if([self respondsToSelector:@selector(setAutomaticallyAdjustsScrollViewInsets:)]){
          self.automaticallyAdjustsScrollViewInsets = NO;
    }
     
    3.再做ios7兼容的时候最好让所有的UIViewController继承一个自己定义的UIViewController,然后好统一管理。
     
    4.UITableView cell的分割线不能靠左的解决方法
    添加一句:
    [UITableViewappearance].separatorInset=UIEdgeInsetsZero;
     
    5.适配IOS7时使用edgesForExtendedLayout遇到的问题
    代码是navigationBar+tabBar组成的
    在viewDidLoad里加了如下代码,
    if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {
          self.edgesForExtendedLayout = UIRectEdgeNone;
          self.extendedLayoutIncludesOpaqueBars = NO;  
          self.modalPresentationCapturesStatusBarAppearance = NO; 

          self.navigationController.navigationBar.barTintColor =[UIColor grayColor];
          self.tabBarController.tabBar.barTintColor =[UIColor grayColor];
    }

    加了之后UI显示正常了,即没有上移20的高度。
    问题是,当运行程序,自动进入到tabBar对应的第一个页面时,navigationBar和tabBar会出现黑色的背景,一小会会消失,才变成自己设置的背景色。
    如果注释掉上面代码,进入程序时不会出现黑色背景,但是里面的UI会上移20的高度...
    解决方法:
    self.navigationController.navigationBar.translucent = NO;
            self.tabBarController.tabBar.translucent = NO;
     
     
     
    copy from  http://blog.csdn.net/yongyinmg/article/details/23861853
  • 相关阅读:
    用 ArcMap 发布 ArcGIS Server Feature Server Feature Access 服务 SQL Server版
    ArcGIS Server Manager 重置密码
    接口自动化过程中遇到的问题?
    接口自动化的闭环?
    每天有80亿的文件需要存储,你会怎么设计存储和检索?
    数据库之索引
    java之高并发锁
    测试环境搭建
    shell基本语法
    RPC和HTTP
  • 原文地址:https://www.cnblogs.com/wangyang1213/p/5420049.html
Copyright © 2020-2023  润新知