最近做了iOS 9的适配,程序出现大量警告也做了些处理,写出来分先给大家。

一、iOS 9适配

问题一:

<Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.  

出错原因:设置app的状态栏样式的使用使用了旧的方式,在info.plist里面设置了View controller-based status bar appearance为NO,默认为YES,一般式iOS6的时候使用这种方式,iOS7,8也兼容,但是到了iOS9就报了警告。以前我们使用代码为[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent];以前我们通过上面代码改变状态了颜色
 
解决办法::
  1.删除 原先的设置代码[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  2.修改方式将View controller-based status bar appearance设置为YES,然后使用新的方式来实现状态栏的样式。
  3.如果你是用UINavigationController只需要在appdelegate里面添加 [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack]就行。

问题二:

-canOpenURL: failed for URL: "weixin://app/wx9c8771d3c07dfd30/" - error: "This app is not allowed to query for scheme weixin"

解决办法:

  info.plist加入
  <key>LSApplicationQueriesSchemes</key>
  <array>
  <string>urlscheme1</string>
  <string>urlscheme2</string>
  <string>urlscheme3</string>
  <string>urlscheme4</string>
  </array>
问题三:
  Bitcode问题
  原因:Xcode7 及以上版本会默认开启 bitcode 。。
解决方法:
  1.更新library使包含Bitcode,否则会出现以上的警告。
  2.关闭Bitcode,Build Settings”->”Enable Bitcode”改成"NO"
问题四:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app‘s Info.plist file.

在iOS9中,将原http协议改成了https协议,使用 TLS1.2 SSL加密请求数据。
解决方法:
在info.plist 加入key
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
二、消除warning
warning 1
  warning :no rule to process file ’…/BBCommmunityVerify.h’ of type sourcecode.c.h for architecture arm64
  解决办法:

  可以看出是某个.h文件出了问题,在Build Phases -> Compile Sources 里面删除该文件即可
 
warning 2:
  warning:Automatic Preferred Max Layout Width before iOS 8.0
  出现条件:
  the warning will appear if

  (1) you're using auto layout,
  (2) "Automatic" is set for a multiline label [you can check this in the size inspector for the label], and
  (3) your deployment target < iOS 8.
  上面的意思是警告出现的三个条件
  1.使用自动布局
  2.label多行且设置为.Automatic
  3.版本低于iOS 8.
 解决办法:
 - (void)layoutSubviews {
[super layoutSubviews];
CGFloat availableLabelWidth = self.label.frame.size.width;
self.label.preferredMaxLayoutWidth = availableLabelWidth;
[super layoutSubviews];
}

The first call to [super layoutSubviews] will evaluate the constraints on the label (since it’s a direct subview) and change its frame accordingly. At this point the width is useful, but the height is not; the height was set using the label’s intrinsic content size, which in turn relied on a preferred max layout width value that is now stale.

Now we know the actual width of the label, we set that as its max layout width. Internally, this causes the label to invalidate its intrinsic content size; when it’s next queried, it will have the accurate height for its current width. With all layout information in place, we call[super layoutSubviews] again.
大概意思是第一个[super layoutSubviews]; 获得width,然后设置self.label.preferredMaxLayoutWidth,第二个用来计算行数。
 
warning 3:
  directory not found for option ‘-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'
 

去掉警告的办法如下:
1选择工程, 编译的 (targets)
2选择 Build Settings 菜单
3查找 Library Search Paths 和 Framework Search Paths,-L 找Library Search Paths,-F找Framework Search Paths 删掉编译报warning的路径即OK
 
warning 4:
  warning: Plain Style unsupported in a Navigation Item
解决办法:

  1.找到文件,open as source code 搜索 style=“plain" 
  2.修改<barButtonItem key="rightBarButtonItem" style="plain" id="juB-DL-F9i">
  为<barButtonItem key="rightBarButtonItem" id="juB-DL-F9i">
  也就是删除style=“plain"
 
warning 5
  warning:Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:
错误原因: storyboard中存在无法获得的控制器。既不是initial控制器,也没有idenifier;
解决办法:没用就删除,有用的话添加identifier;
 
warning 6:

  warning:Frame for “Phone Text Filed” will be  different at run time 
  这个简单,布局报黄,更新布局即可,可设置快捷键。。。
 
 
 

iOS9适配+warning消除的更多相关文章

  1. 整理iOS9适配中出现的坑(图文)

    原文: http://www.cnblogs.com/dsxniubility/p/4821184.html 整理iOS9适配中出现的坑(图文)   本文主要是说一些iOS9适配中出现的坑,如果只是要 ...

  2. fir.im Weekly - iOS9 适配开发教程

    期待已久的 iOS 9 发布了,很多人更新完毕得出结论:这是值得升级的版本.随之而来的是适应 iOS9 开发技术.本期 Weekly 收集了一些关于 iOS9 相关的开发资源,希望对你有帮助. iOS ...

  3. iOS9 适配

    iOS适配的相关内容的整理 之前iOS开发者一直很庆幸自己不用像安卓开发者那样适配各种不同类型的机型,但如今随着iPhone各种机型的改变,适配也成了我们开发中必须会的内容了.首先我们来了解一下对于不 ...

  4. 整理iOS9适配

    整理iOS9适配 本文主要是说一些iOS9适配中出现的坑,如果只是要单纯的了解iOS9新特性可以看瞄神的开发者所需要知道的 iOS 9 SDK 新特性.9月17日凌晨,苹果给用户推送了iOS9正式版, ...

  5. iOS开发——适配篇&iOS9适配

    iOS9适配 1. Demo1_iOS9网络适配_ATS:改用更安全的HTTPS [摘要]iOS9把所有的http请求都改为https了:iOS9系统发送的网络请求将统一使用TLS 1.2 SSL.采 ...

  6. iOS9适配中出现的一些常见问题

    本文主要是说一些iOS9适配中出现的坑,如果只是要单纯的了解iOS9新特性可以看瞄神的开发者所需要知道的 iOS 9 SDK 新特性.9月17日凌晨,苹果给用户推送了iOS9正式版,随着有用户陆续升级 ...

  7. IOS9适配 MARK

    最近做了iOS 9的适配,程序出现大量警告也做了些处理,写出来分先给大家. 一.iOS 9适配 问题一: <Error>: CGContextSaveGState: invalid con ...

  8. ios9适配系列教程——ios9新变化

    Demo1_iOS9网络适配_改用更安全的HTTPS iOS9把所有的http请求都改为https了:iOS9系统发送的网络请求将统一使用TLS 1.2 SSL.采用TLS 1.2 协议,目的是 强制 ...

  9. iOS9适配系列教程

    链接地址:http://www.open-open.com/lib/view/open1443194127763.html 中文快速导航: iOS9网络适配_ATS:改用更安全的HTTPS(见Demo ...

随机推荐

  1. debian系(Ubuntu)安装jenkins(持续集成)

    wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'ec ...

  2. Http服务器性能测试工具ab..

    -A auth-username:password 对服务器提供BASIC认证信任.用户名和密码由一个:隔开,并以base64编码形式发送,无论服务器是否需要(即,是否发送了401认证需求代码),此字 ...

  3. Javascript 开发IDE

    俗话说,工欲行其事,必先利其器.开发的时候有一款好的IDE,对开发效率的提升是非常帮助的,在此强烈推荐Webstorm,官网网址http://www.jetbrains.com/webstorm/ 主 ...

  4. ECstore报表不显示解决

    最近研究ECSTORE发现后台报表显示空白,Google了一下发现N多统一的做法,直接往表里插几条数据.呵呵,更深入一点 1.要显示报表功能首先要确保已经配置好contab的定时任务,定时任务能够执行 ...

  5. [T]各种字符串Hash函数比较

    常用的字符串Hash函数还有ELFHash,APHash等等,都是十分简单有效的方法.这些函数使用位运算使得每一个字符都对最后的函数值产生影响.另外还有以MD5和SHA1为代表的杂凑函数,这些函数几乎 ...

  6. CentOS7配置Nodejs环境安装记录

    今天购买了阿里云服务器,系统选的是CentOS7,下面记录下在它上面安装Nodejs环境的过程,本次操作是直接连接的阿里云服务器的管理终端. 1.由于是纯净的环境,先通过以下命令安装nodejs编译及 ...

  7. CM源码同步编译教程

    一.操作系统 准备一个ubuntu安装镜像,我用的是12.10. 安装系统时请安装到30g以上的盘,最好就50g以上啦 安装教程不多说,网上很多教程,这里我推荐用自带的wubi工具安装,比较方便 用虚 ...

  8. 关于nginx架构探究(2)

    nginx 数据结构 1.Hash table nginx 对虚拟主机的管理使用到了HASH数据结构,假设配置文件里有如下的配置. Server{ listen 192.168.0.1 server_ ...

  9. 扩展Log4j支持JNDI数据源

    log4j.properties配置文件: log4j.rootLogger=INFO,db #使用log4j扩展支持JNDI数据源 log4j.appender.db=com.qdgswx.log4 ...

  10. CRACKING THE CODING INTERVIEW 笔记(1)

    1. Arrays and Strings 1.1 Hash Tables 哈希表,简单的说就是由一个数组和一个hash函数组成实现key/value映射并且能高效的查找的数据结构.最简单的想法就是将 ...