作者ppcat (忙碌)
看板MacDev
标题[问题] iOS mapview annotation 显示问题
时间Thu Oct 31 10:49:38 2013
请教各位前辈~
目前我在模拟器 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
1F:→ howdiun:纯猜测,annotation不在可见范围内 10/31 11:17
2F:→ ppcat:请问可见范围是指region吗? 10/31 11:28
3F:→ ppcat:有些地方是 我点了某个annotation 再关掉annotationview 10/31 11:29
4F:→ ppcat:这时候同萤幕范围其他的 annotation 就会出现了@@ 10/31 11:29
5F:→ howdiun:其实这个delegate应该越简单越好 10/31 13:56
6F:→ howdiun:做太多事会影响scroll的效能 10/31 13:58
7F:→ ppcat:嗯 我也在看效能的影响部分QQ 感谢howdiun大 10/31 19:42
8F:→ ppcat:发现问题好像是出在sendAsynchronousRequest的block中 10/31 19:43
9F:→ ppcat:在sendAsynchronousRequest的completionHandler里add会怪怪 10/31 19:44