2017-09-13 72 views
14

所以我的代码工作正常,但我的记录器充满了这条消息。有没有办法摆脱它或压制它?MKAnnotationView层不是预期类型:MKLayer

PostAnnotation.swift

class PostAnnotation: MKPointAnnotation { 

    //MARK: properties 
    let post: Post 

    //MARK: initialization 
    init(post: Post) { 
     self.post = post 
     super.init() 
     self.coordinate = CLLocationCoordinate2D(latitude: post.latitude, longitude: post.longitude) 
     self.title = post.title 
     self.subtitle = post.timeString() 
    } 

} 

添加注释

let annotation = PostAnnotation(post: post) 
self.map.addAnnotation(annotation) 

FUNC MapView的

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { 

    if annotation is MKUserLocation { 
     return nil 
    } 

    var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "pin") as? MKPinAnnotationView 
    if annotationView == nil { 
     annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "pin") 
    } else { 
     annotationView?.annotation = annotation 
    } 

    if let annotation = annotation as? PostAnnotation { 
     annotationView?.pinTintColor = UIColor.blue 
     annotationView?.canShowCallout = true 
     annotationView?.rightCalloutAccessoryView = UIButton(type: .infoLight) 
     annotationView?.animatesDrop = true 
    } 

    return annotationView 
} 

删除此功能将删除消息

+1

您使用的是哪种版本的Xcode?我开始用Xcode 9 GM发送同样的消息。 MKPinAnnotationView调用正在触发我的事件。 – Refactor

+1

@refactor Xcode 9 GM – rmaes4

+0

我至少从Xcode 9 beta 4中看到了这个错误。 – Frost

回答

15

这是iOS 11中的一个错误,因为MKLayer不是公共类。

我简单地忽略了这条消息,但是如果它困扰着你:为了使这个警告消失,你可以在方案的环境页面中设置OS_ACTIVITY_MODE=disable。但要小心,你也会沉默其他的操作系统警告。

Scheme Editor