我遇到了问题:我必须知道何时将地图数据加载到地图视图。我使用了以下方法。
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
{
//Some custom code if Map is loaded
}
Apple更改了Map,现在调用了该方法,但map仍在加载。
你有什么想法吗?
答案 0 :(得分:0)
我已经修好了。首先,我使用自定义代码
创建了一个函数-(void)customCode(id)object
{
MKMapView* mapView = (MKMapView *)object;
...
}
在函数mapViewDidFinishLoadingMap中我设置了
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
{
CGFloat systemVersion = [[[ UIDevice currentDevice ] systemVersion ] floatValue ];
if( systemVersion < 6 )
{
[self updateMap:mapView];
}
else
{
[self myMapViewDidFinishLoaded:mapView];
}
}
和
-(void)onMapTimed:(id)mapView
{
[self performSelectorOnMainThread:@selector(customCode:) withObject:((NSTimer*)mapView).userInfo waitUntilDone:NO];
_mapTimer = nil;
}
-(void)myMapViewDidFinishLoaded:(id)mapView;
{
if(_mapTimer)
{
[_mapTimer invalidate];
[_mapTimer release];
_mapTimer = nil;
}
_mapTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(onMapTimed:) userInfo:mapView repeats:NO];
}
它对我有用。