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
}
删除此功能将删除消息
您使用的是哪种版本的Xcode?我开始用Xcode 9 GM发送同样的消息。 MKPinAnnotationView调用正在触发我的事件。 – Refactor
@refactor Xcode 9 GM – rmaes4
我至少从Xcode 9 beta 4中看到了这个错误。 – Frost