【XCode7+iOS9】http网路连接请求、MKPinAnnotationView自定义图片和BitCode相关错误

简介:

更新了iOS9和XCode7,之后,Swift变成了2.0,有了新的语法习惯,iOS也加强了安全方面的限制。我们原本的项目就会出现不少问题。先来看我之前的项目中出现的3个错误吧和相关的解决办法吧。

1. HTTP网络请求错误。

因为iOS9默认使用HTTPS的链接方式,所以如果你的程序以前使用的是HTTP方式进行网络链接,那么更新了之后,你的程序可能不会有bug,但是当运行的时候,遇到访问HTTP的接口时,就会出现这样的错误提示:

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.
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
所以,解决的办法是在info.plist中添加进去新的项目:NSAppTransportSecurity 和 NSAllowsArbitraryLoads


注意,NSAppTransportSecurity的类型是Dictionary,NSAllowsArbitraryLoads的类型是Boolean,另外NSAllowsArbitraryLoads一定要放置在NSAppTransportSecurity的二级目录之下。


2. 自定义地图Annotation的图标

在iOS9之前,我们基本上是偏向于使用MKPinAnnotationView的,因为MKPinAnnotationView如果设置了自定义的图片,就会显示之;如果不设置自定义的图片,就会默认显示大头针的样式。但是注意,到了iOS9,就不能使用MKPinAnnotationView这个类型了,因为它将不再支持自定义的图片,如果想要显示自定义的图片的话,必须使用MKAnnotationView这个类。

但是这里有个很尴尬的地方。比如你的工程里面,有部分地图上的点显示默认的大头针,有部分显示自定义的图片,需要在你的

mapView viewForAnnotation代理中返回两个不同类型的Annotation,例如下面我的工程中的代码(因为这个工程时间比较久,所以用的还是OC,swift的话基本类似):

static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";
[mapView dequeueReusableAnnotationViewWithIdentifier:BridgeAnnotationIdentifier];
if (level==0 || level == 1) {
            MKPinAnnotationView* PinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier];
            PinView.pinColor = MKPinAnnotationColorRed;
            PinView.opaque=NO;
            PinView.canShowCallout = YES;
            return PinView;
}else if(level==2){
            MKAnnotationView* customView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier];
            customView.canShowCallout = YES;
            customView.opaque=NO;
	......
            return customPinView;
        }


3. 最后来看一个新的错误关于BitCode

(null): URGENT: all bitcode will be dropped because '/Users/myname/Library/Mobile Documents/com~apple~CloudDocs/foldername/appname/GoogleMobileAds.framework/GoogleMobileAds(GADSlot+AdEvents.o)' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note: This will be an error in the future.

这个错误一般会出现在引入的第三方的框架中出现,是关于bitcode的。

Note: For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS apps, bitcode is required.

所以解决的办法也很简单,步骤如下(从Statckoverflow上传过来的):



注意一下,这个只有在Xcode7下面才有。

暂时就只遇到这3个问题,有新的问题,我会接着更新blog。

目录
相关文章
|
JSON 监控 API
掌握使用 requests 库发送各种 HTTP 请求和处理 API 响应
本课程全面讲解了使用 Python 的 requests 库进行 API 请求与响应处理,内容涵盖环境搭建、GET 与 POST 请求、参数传递、错误处理、请求头设置及实战项目开发。通过实例教学,学员可掌握基础到高级技巧,并完成天气查询应用等实际项目,适合初学者快速上手网络编程与 API 调用。
1378 130
HTTP协议中请求方式GET 与 POST 什么区别 ?
GET和POST的主要区别在于参数传递方式、安全性和应用场景。GET通过URL传递参数,长度受限且安全性较低,适合获取数据;而POST通过请求体传递参数,安全性更高,适合提交数据。
1038 2
|
JSON JavaScript API
Python模拟HTTP请求实现APP自动签到
Python模拟HTTP请求实现APP自动签到
|
数据采集 JSON Go
Go语言实战案例:实现HTTP客户端请求并解析响应
本文是 Go 网络与并发实战系列的第 2 篇,详细介绍如何使用 Go 构建 HTTP 客户端,涵盖请求发送、响应解析、错误处理、Header 与 Body 提取等流程,并通过实战代码演示如何并发请求多个 URL,适合希望掌握 Go 网络编程基础的开发者。
|
Web App开发 前端开发 Android开发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
使用MAT分析内存泄露 对于大型服务端应用程序来说,有些内存泄露问题很难在测试阶段发现,此时就需要分析JVM Heap Dump文件来找出问题。
1078 0
|
Web App开发 监控 前端开发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
系统的升级涉及各个架构组件,细节很多。常年累月的修修补补使老系统积累了很多问题。 系统升级则意味着需要repair之前埋下的雷,那为何还要升级,可以考虑以下几个方面 成熟老系统常见问题: 1. 缺乏文档(这应该是大小公司都存在的问题。
853 0
|
Web App开发 前端开发 Java
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
java链接MongoDB处理大量数据时经常碰到cursor not found 的异常,其实是超时所致 Exception in thread "main" com.
1087 0
|
Web App开发 大数据
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
                                                                               1.
2033 0
|
Web App开发 前端开发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
PipeMapRed.waitOutputThreads(): subprocess failed with code X ,这里code X对应的信息如下:error code 1: Operation not perm...
1270 0
|
Web App开发 前端开发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
从hadoop移除机器把需要移除的机器增加到exclueds文件中,强制刷新datanode列表,等待decommission 状态正常后,即可停机下架,如有必要在namenode执行balancer操作。
932 0