MKMap在iOs6中的工作原理不正确

时间:2012-09-26 09:27:00

标签: iphone objective-c map ios6

我遇到了问题:我必须知道何时将地图数据加载到地图视图。我使用了以下方法。

- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
{
    //Some custom code if Map is loaded
}

Apple更改了Map,现在调用了该方法,但map仍在加载。

你有什么想法吗?

1 个答案:

答案 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];

}

它对我有用。