Iphone 异步加载MKMapView?

Iphone 异步加载MKMapView?,iphone,mkmapview,Iphone,Mkmapview,当我第一次打开MKMapView时,我的应用程序在加载时似乎会暂停。我假设这是因为它不异步加载 我有什么办法可以绕过这件事吗。加载时,您无法切换选项卡或执行任何操作 谢谢 编辑:这是我的viewDidLoad方法: CGRect bounds = self.view.bounds; mapView = [[MKMapView alloc] initWithFrame:bounds]; mapView.mapType=MKMapTypeStandard; mapView.s

当我第一次打开MKMapView时,我的应用程序在加载时似乎会暂停。我假设这是因为它不异步加载

我有什么办法可以绕过这件事吗。加载时,您无法切换选项卡或执行任何操作

谢谢

编辑:这是我的
viewDidLoad
方法:

CGRect bounds = self.view.bounds;
    mapView = [[MKMapView alloc] initWithFrame:bounds];
    mapView.mapType=MKMapTypeStandard;
    mapView.showsUserLocation = YES;
    mapView.delegate = self;

    [self.view insertSubview:mapView atIndex:0];

    NSArray *mapTypes = [NSArray arrayWithObjects:@"Standard",@"Satellite",@"Hybrid",nil];

    mapType = [[UISegmentedControl alloc] initWithItems:mapTypes];
    [mapType setSegmentedControlStyle:UISegmentedControlStyleBar];
    [mapType setCenter:CGPointMake(210, 345)];
    [mapType setSelectedSegmentIndex:0];
    [mapType setTintColor:[UIColor darkGrayColor]];
    [mapType addTarget:self action:@selector(changeType:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:mapType];

    // refresh button...
    UISegmentedControl *refreshButton = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Refresh",nil]] autorelease];
    [refreshButton setSegmentedControlStyle:UISegmentedControlStyleBar];
    [refreshButton setCenter:CGPointMake(self.view.frame.size.width-((refreshButton.frame.size.width/2)+5),(refreshButton.frame.size.height/2)+5)];
    [refreshButton setMomentary:YES];
    [refreshButton setTintColor:[UIColor darkGrayColor]];
    [refreshButton addTarget:self action:@selector(updateMarkers) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:refreshButton];


    UIBarButtonItem *leftBarButton = [[[UIBarButtonItem alloc] initWithTitle:@"List" style:UIBarButtonItemStylePlain target:self action:@selector(goToList)] autorelease];
    [self.navigationItem setRightBarButtonItem:leftBarButton animated:YES];

    // refresh label
    refreshView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, self.view.frame.size.width-74, 40)];
    [refreshView setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.8]];
    [refreshView.layer setCornerRadius:5];
    [self.view addSubview:refreshView];

    UILabel *refreshLabel = [[[UILabel alloc] initWithFrame:CGRectMake(5, 5, refreshView.frame.size.width-10, refreshView.frame.size.height-10)] autorelease];
    [refreshLabel setTextColor:[UIColor whiteColor]];
    [refreshLabel setBackgroundColor:[UIColor clearColor]];
    [refreshLabel setFont:[UIFont fontWithName:@"Helvetica" size:12]];
    [refreshLabel setNumberOfLines:2];
    [refreshLabel setLineBreakMode:UILineBreakModeWordWrap];
    [refreshLabel setText:@"Move the map and press 'refresh' to load new results."];
    [refreshView addSubview:refreshLabel];

    [NSTimer scheduledTimerWithTimeInterval:10 target:refreshView selector:@selector(removeFromSuperview) userInfo:nil repeats:NO];

我不相信这是真的。你能提供一些特定的代码吗?我也不能-文档中说它是异步加载的,并且有委托方法。基本上,地图是灰色的,带有网格,从这一点开始,直到完全加载并将用户的当前位置放在地图上,它只是暂停一会儿。显然,互联网连接越弱,暂停的时间就越长。我将提供
viewDidLoad
方法。类的其余部分是巨大的。编辑操作-下一件事直到
didUpdateUserLocation
才发生,它只是将地图集中在用户位置并缩放。对不起,当你说“暂停”时,你的意思是UI线程被阻塞,因为你无法导航到另一个视图或以其他方式与UI交互?是的。。。没错,地图不会移动,您无法更改选项卡,按钮不起作用。:)我不相信这是真的。你能提供一些特定的代码吗?我也不能-文档中说它是异步加载的,并且有委托方法。基本上,地图是灰色的,带有网格,从这一点开始,直到完全加载并将用户的当前位置放在地图上,它只是暂停一会儿。显然,互联网连接越弱,暂停的时间就越长。我将提供
viewDidLoad
方法。类的其余部分是巨大的。编辑操作-下一件事直到
didUpdateUserLocation
才发生,它只是将地图集中在用户位置并缩放。对不起,当你说“暂停”时,你的意思是UI线程被阻塞,因为你无法导航到另一个视图或以其他方式与UI交互?是的。。。没错,地图不会移动,您无法更改选项卡,按钮不起作用。:)