【发布时间】:2012-03-05 14:59:47
【问题描述】:
我在 iPad 上使用以下代码进行了测试。
如果我像下面的代码一样添加 MyOverlay,MKMapView 加载默认地图图块会变慢,即使在 drawMapRect 中什么也不做。
如果我从 MKMapView 中删除 MyOverlay,默认地图图块的加载速度会再次变快。
我想知道调用 drawMapRect 时后台做了什么。
或者下面的代码有什么性能问题?
[代码]
@implementation MyOverlay
-(id) init
{
self = [super init];
boundingMapRect = MKMapRectWorld;
boundingMapRect.origin.x += 1048600.0;
boundingMapRect.origin.y += 1048600.0;
coordinate = CLLocationCoordinate2DMake(0, 0);
return self;
}
...
@end
@implementation MyOverlayView
- (id) initWithOverlay:(id<MKOverlay>)overlay
{
self = [super initWithOverlay:overlay];
...
return self;
}
- (BOOL) canDrawMapRect:(MKMapRect) sm zoomScale:(MKZoomScale)zoomScale
{
return true;
}
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext: CGContextRef)context
{
return; // do nothing, but map loading become slower 'much'.
}
@end
【问题讨论】:
标签: ios performance mkmapview mkoverlay