MKMap在iOs6中的工作原理不正确 [英] MKMap works incorrect in iOs6

查看:139
本文介绍了MKMap在iOs6中的工作原理不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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
}



<苹果改变了Map,现在调用了方法,但是地图仍在加载。

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

你有什么想法吗?

推荐答案

我已经修好了。首先,我使用自定义代码创建了一个函数

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

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

在函数mapViewDidFinishLoadingMap中我设置

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

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

}

它对我有用。

这篇关于MKMap在iOs6中的工作原理不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆