zoukankan      html  css  js  c++  java
  • 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;
  • 相关阅读:
    Python Data Type
    Python 基础二
    Python的基础知识
    查看当前进程
    linux 通过服务名称查找目录
    在linux下登录MySQL,发现无法输入密码?
    多米诺骨牌效应
    MySQL MVCC底层原理详解MySQL MVCC底层原理详解
    C#保留小数点后几位
    在ubuntu服务器上安装mysql并配置外网访问
  • 原文地址:https://www.cnblogs.com/mgbert/p/3490569.html
Copyright © 2011-2022 走看看