MKAnnotationView图层不是预期类型:MKLayer [英] MKAnnotationView layer is not of expected type: MKLayer

查看:139
本文介绍了MKAnnotationView图层不是预期类型:MKLayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的代码工作正常,但我的记录器充满了这条消息。有没有办法摆脱它或抑制它?

So my code works fine but my logger is riddled with this message. Is there a way to get rid of it or suppress it?

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
}

删除此函数删除消息

推荐答案

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

This is a bug in iOS 11, since MKLayer is not a public class.

我只是忽略了这条消息,但如果它困扰你:要使这个警告静音,你可以设置 OS_ACTIVITY_MODE =在方案的环境页面中禁用。但要注意,你也会沉默其他操作系统警告。

I'd simply ignore the message, but if it's bothering you: To silence this warning, you can set OS_ACTIVITY_MODE=disable in the scheme's environment page. Beware though, you will silence other OS warnings as well.

这篇关于MKAnnotationView图层不是预期类型:MKLayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆