0

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

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

苹果更改了地图,现在调用了该方法,但地图仍在加载。

你有什么想法?

4

1 回答 1

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

}

这个对我有用。

于 2012-10-01T07:47:57.527 回答