[問題] iOS mapview annotation 顯示問題

看板MacDev作者 (忙碌)時間11年前 (2013/10/31 10:49), 編輯推噓0(009)
留言9則, 2人參與, 最新討論串1/1
請教各位前輩~ 目前我在模擬器 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

10/31 11:17, , 1F
純猜測,annotation不在可見範圍內
10/31 11:17, 1F

10/31 11:28, , 2F
請問可見範圍是指region嗎?
10/31 11:28, 2F

10/31 11:29, , 3F
有些地方是 我點了某個annotation 再關掉annotationview
10/31 11:29, 3F

10/31 11:29, , 4F
這時候同螢幕範圍其他的 annotation 就會出現了@@
10/31 11:29, 4F

10/31 13:56, , 5F
其實這個delegate應該越簡單越好
10/31 13:56, 5F

10/31 13:58, , 6F
做太多事會影響scroll的效能
10/31 13:58, 6F

10/31 19:42, , 7F
嗯 我也在看效能的影響部分QQ 感謝howdiun大
10/31 19:42, 7F

10/31 19:43, , 8F
發現問題好像是出在sendAsynchronousRequest的block中
10/31 19:43, 8F

10/31 19:44, , 9F
在sendAsynchronousRequest的completionHandler裡add會怪怪
10/31 19:44, 9F
文章代碼(AID): #1ISSL8iU (MacDev)
文章代碼(AID): #1ISSL8iU (MacDev)