[問題] iOS mapview annotation 顯示問題
請教各位前輩~
目前我在模擬器 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
10/31 11:17, 1F
→
10/31 11:28, , 2F
10/31 11:28, 2F
→
10/31 11:29, , 3F
10/31 11:29, 3F
→
10/31 11:29, , 4F
10/31 11:29, 4F
→
10/31 13:56, , 5F
10/31 13:56, 5F
→
10/31 13:58, , 6F
10/31 13:58, 6F
→
10/31 19:42, , 7F
10/31 19:42, 7F
→
10/31 19:43, , 8F
10/31 19:43, 8F
→
10/31 19:44, , 9F
10/31 19:44, 9F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章