MKMap works incorrect in iOs6

2019-03-04 22:22发布

问题:

I have a problem: I have to know when map data are loaded to the Map view. I used the following method.

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

Apple changed Map and now the method is called but map is still loading.

Do you have any ideas?

回答1:

I've fixed it. At first, I created a function with my custom code

-(void)customCode(id)object
{
    MKMapView* mapView = (MKMapView *)object;
    ...
}

In the function mapViewDidFinishLoadingMap I set

- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
{

    CGFloat systemVersion = [[[ UIDevice currentDevice ] systemVersion ] floatValue ];

    if( systemVersion < 6 )
    {
        [self updateMap:mapView];
    }
    else
    {
        [self myMapViewDidFinishLoaded:mapView];
    }
}

And

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

}

It works for me.