MKMap works incorrect in iOs6

我的未来我决定 提交于 2019-12-20 06:20:45

问题


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.



来源:https://stackoverflow.com/questions/12598569/mkmap-works-incorrect-in-ios6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!