看板 MacDev 關於我們 聯絡資訊
請教各位前輩~ 目前我在模擬器 mapview 顯示區域內打一些 annotation 上去 可是拖曳到有些區域的 annotation 不會立刻顯示出來? 目前是用 regionDidChangeAnimated 來做 測試 code: - (void) mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated { NSLog(@"regionDidChangeAnimated"); // 清除 annotations (是否會有效能問題? @@) [self.mapView removeAnnotations:[self.mapView annotations]]; CGPoint nePoint = CGPointMake(mapView.bounds.origin.x + mapView.bounds.size.width, mapView.bounds.origin.y); CGPoint swPoint = CGPointMake((mapView.bounds.origin.x), (mapView.bounds.origin.y + mapView.bounds.size.height)); // 計算螢幕東北及西南座標 CLLocationCoordinate2D neCoord = [mapView convertPoint:nePoint toCoordinateFromView:mapView]; CLLocationCoordinate2D swCoord = [mapView convertPoint:swPoint toCoordinateFromView:mapView]; // 根據東北及西南座標查詢該螢幕範圍內的點 // ....... // ....... // 加入地圖 (POI implements MKAnnotation Protocol) for (POI *poi in poiList) { [self.mapView addAnnotation:poi]; } NSLog(@"annotation count: %d", [[self.mapView annotations] count]); } 每次拖曳地圖都會觸發 regionDidChangeAnimated 並印出 annotation count 可是某些區域 annotation count 的值大於 0 可是地圖上沒有出現 annotation 不知道是否有什麼地方我搞錯了呢? 謝謝~ p.s. 環境是 Xcode 5.0, iOS 7.0 Simulator iPhone Retina 3.5 inch -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.251.197.181
howdiun:純猜測,annotation不在可見範圍內 10/31 11:17
ppcat:請問可見範圍是指region嗎? 10/31 11:28
ppcat:有些地方是 我點了某個annotation 再關掉annotationview 10/31 11:29
ppcat:這時候同螢幕範圍其他的 annotation 就會出現了@@ 10/31 11:29
howdiun:其實這個delegate應該越簡單越好 10/31 13:56
howdiun:做太多事會影響scroll的效能 10/31 13:58
ppcat:嗯 我也在看效能的影響部分QQ 感謝howdiun大 10/31 19:42
ppcat:發現問題好像是出在sendAsynchronousRequest的block中 10/31 19:43
ppcat:在sendAsynchronousRequest的completionHandler裡add會怪怪 10/31 19:44