mapview在加载所有数据之前未显示

时间:2011-01-29 13:32:01

标签: iphone mkmapview

我有一个应用程序,它有mapview。

问题是我想要显示地图。意味着现在加载所有数据然后它显示mapview。我想在加载之前显示mapview。我怎样才能做到这一点 ?

编辑:

对于show map我使用此[self performSelector:@selector(methoname) withObject:nil afterDelay:0.02];

但是通过这个问题生成.problem,它显示了两次活动指标。任何其他的东西,比如performselector但没有活动指示器。

enter image description here

我不想展示这件事。

1 个答案:

答案 0 :(得分:0)

你想看看多线程。

基本上,您应该在后台线程中检索数据。如果你正在做你现在正在做的事情(在主线程中加载所有内容),在加载所有内容之前,无法更新UI。

所以,做这样的事情:

-(void)viewDidLoad{
    mapView.hidden = NO;
    [self performSelectorInBackground:@selector(getExtraMapData)];
}

-(void)getExtraMapData{ NSAutoReleasePool *pool = [[NSAutoreleasePool alloc] init]; [self downloadMapData]; [map addTheDataIDownloaded];//I've never used the mapView, // so I don't know it's methods. [pool release]; }
-(void)downloadMapData{ NSURL *mapDataURL = [NSURL URLWithString:@"http://aURLWithInfoForMyMap.com"]; NSData *mapData = [NSData dataWithContentsOfURL:mapDataURL]; }
相关问题