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

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

1. HTTP网络请求错误。

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

 

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这个类。app

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

mapView viewForAnnotation代理中返回两个不一样类型的Annotation,例以下面个人工程中的代码(由于这个工程时间比较久,因此用的仍是OC,swift的话基本相似):ide

 

 

 

[objc]  view plain copy
 
  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.ui

这个错误通常会出如今引入的第三方的框架中出现,是关于bitcode的。this

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.spa

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

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

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

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

相关文章
相关标签/搜索