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;
     
     
     
    copy from  http://blog.csdn.net/yongyinmg/article/details/23861853
  • 相关阅读:
    MOSS中的User的Title, LoginName, DisplayName, SID之间的关系
    如何在Network Monitor中高亮间隔时间过长的帧?
    SharePoint服务器如果需要安装杀毒软件, 需要注意什么?
    如何查看SQL Profiler? 如何查看SQL死锁?
    什么是Telnet
    The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain.
    Windows SharePoint Service 3.0的某个Web Application无搜索结果
    网络连接不上, 有TCP错误, 如果操作系统是Windows Server 2003, 请尝试一下这里
    在WinDBG中查看内存的命令
    The virtual machine could not be started because the hypervisor is not running
  • 原文地址:https://www.cnblogs.com/wangyang1213/p/5420049.html
Copyright © 2011-2022 走看看