2017-09-13 32 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