zoukankan      html  css  js  c++  java
  • 【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的话基本类似):

     

     

     

    [objc] view plaincopy
     
    1. static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";  
    2. [mapView dequeueReusableAnnotationViewWithIdentifier:BridgeAnnotationIdentifier];  
    3. if (level==0 || level == 1) {  
    4.             MKPinAnnotationView* PinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier];  
    5.             PinView.pinColor = MKPinAnnotationColorRed;  
    6.             PinView.opaque=NO;  
    7.             PinView.canShowCallout = YES;  
    8.             return PinView;  
    9. }else if(level==2){  
    10.             MKAnnotationView* customView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier];  
    11.             customView.canShowCallout = YES;  
    12.             customView.opaque=NO;  
    13.     ......  
    14.             return customPinView;  
    15.         }  

     

    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。

    转自http://blog.csdn.net/u011156012/article/details/48707313   

  • 相关阅读:
    SQL游标操作每隔5分钟时间段数据统计信息
    win64位操作系统下安装pl/sql developer 并登录连接到oracle12c
    分科目统计每科前三名的学生
    merge源表数据移植到目标表新表数据中
    sqlserver表分区
    用SqlBulkCopy批量插入数据到SqlServer数据库表中
    SQL server插入数据后,如何获取自增长字段的值?
    Java创建线程的三种方式
    Java用户线程和守护线程
    Java虚拟机详解
  • 原文地址:https://www.cnblogs.com/isItOk/p/4886557.html
Copyright © 2011-2022 走看看