gpt4 book ai didi

swift - 当我将 MKCircle 添加到 mapKit 的覆盖层时,编译器中出现了很多警告

转载 作者:行者123 更新时间:2023-11-30 11:03:39 25 4
gpt4 key购买 nike

我试图弄清楚如何消除我的委员会上的大量警告,我得出的结论是,这些警告发生在我将叠加层添加到我的mapKit之后

这是我添加叠加层的部分..

    let FireLocation = CLLocationCoordinate2D(latitude: 40.836352, longitude: 14.306019)
let CircularRegion = CLCircularRegion(center: FireLocation, radius: 500, identifier: "fire")
CircularRegion.notifyOnEntry = true
CircularRegion.notifyOnExit = true
self.locatManager.startMonitoring(for: CircularRegion)

let geo = MKCircle(center: FireLocation, radius: CircularRegion.radius)
mapkitView.addOverlay(geo)

之后,我在委托(delegate)方法上自定义这些覆盖...

  func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {

guard let circularOverlay = overlay as? MKCircle else {return MKOverlayRenderer()}


let renderer = MKCircleRenderer(overlay: circularOverlay)
renderer.strokeColor = .red
renderer.fillColor = .yellow
renderer.alpha = 0.3
renderer.lineWidth = 2

return renderer
}

我在控制台上收到的警告...

2018-10-25 15:09:04.919237+0200 SeeFire[37911:13344200] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes. 2018-10-25 15:09:04.921562+0200 SeeFire[37911:13344200] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

如果我评论添加覆盖层的行,则不会出现警告并且一切正常,我做错了什么?

MKCircleRenderer 和 MKCircleView 之间有什么区别,我如何知道应该使用哪一个?

提前感谢您的回答。

最佳答案

尝试以下代码从主线程访问。

DispatchQueue.main.async {
mapkitView.addOverlay(geo)
}

关于swift - 当我将 MKCircle 添加到 mapKit 的覆盖层时,编译器中出现了很多警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52990206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com