在我的应用程序中,我使用MKPolyline来跟踪用户的路径.有时(并非所有时间,我不明白),当新的线段添加到地图时,整条线闪烁.有时却没有.这是用于添加行的代码:
CLLocationCoordinate2D coords[2]; coords[0] = CLLocationCoordinate2DMake(newLocation.coordinate.latitude,newLocation.coordinate.longitude); coords[1] = CLLocationCoordinate2DMake(oldLocation.coordinate.latitude,oldLocation.coordinate.longitude); MKPolyline* line = [MKPolyline polylineWithCoordinates:coords count:2]; [mapView addOverlay:line];
我错过了什么吗?
编辑:这通常发生在应用程序从发送到后台返回时.我不确定为什么,因为我只是添加一个叠加层,而不是修改整个mapView.overlays数组. …对?
解决方法
这可能没有关系,但Apple确实在位置感知编程指南的
Managing the Map’s Overlay Objects部分说明了……
Because the map view is an interface item,any modifications to the
overlays
array should be synchronized and performed on the application’s main thread.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。