我想添加一個mapKit在IB中的viewController,我推動我的導航控制器頂部,但無論在週期中的哪裏我添加註釋看起來像整個事情導致延遲,直到mapKit不呈現包含所有內容的滾動視圖不容易滾動。有沒有辦法在後臺線程的iOS中類似於Android來做到這一點?在導航控制器上推送的viewController中實現MapKit的高效方法?
下面是代碼,即使沒有添加任何註釋,渲染仍然會導致延遲。我很確定還有另一種方法。任何想法?
class DetailViewController: UIViewController , MKMapViewDelegate{
override func viewDidLoad() {
super.viewDidLoad()
self.mapView?.delegate = self
}
//changing the annotation
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if (annotation is MKUserLocation) {
return nil
}
let reuseId = "detailMrker"
var anView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView?.image = UIImage(named:"location.png")
anView?.canShowCallout = true
}
else {
anView?.annotation = annotation
}
return anView
}
}
請顯示您的真實代碼。 – matt