0

我已经为一家商店制作了一个基于 GPS 位置的 Mapkit 应用程序,它在表格视图中有四个位置,当用户选择其中任何一个位置时,它会导航到 MapView 并加载所有内容,但我的问题是在加载时它在加载完成后显示北美地图我得到了所需的地图视图。我需要在加载时显示活动指示器或空白的灰色地图屏幕。 加载时的地图视图 加载完成后

我在我的编码所在的地方以编程方式调用 mapview

UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 372.0f)];
self.view = contentView;
[contentView release];

routeMapView = [[MKMapView alloc] initWithFrame:contentView.frame];
routeMapView.delegate = self;
routeMapView.showsUserLocation = YES;
[contentView addSubview:routeMapView];
[routeMapView release];

routeOverlayView = [[UICRouteOverlayMapView alloc] initWithMapView:routeMapView];
UIBarButtonItem *space = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
UIBarButtonItem *currentLocationButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"reticle.png"] style:UIBarButtonItemStylePlain target:self action:@selector(moveToCurrentLocation:)] autorelease];
UIBarButtonItem *routesButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"list.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showRouteListView:)] autorelease];
self.toolbarItems = [NSArray arrayWithObjects:currentLocationButton, space, /*mapPinButton,*/ routesButton, nil];
[self.navigationController setToolbarHidden:NO animated:NO];
4

1 回答 1

0

Atlast我找到了我的问题的解决方案,首先像这样定义一个局部区域坐标

MKCoordinateRegion region={{0.0,0.0},{0.0,0.0}};

然后为对其所做的更改定义动画,

[routeMapView setRegion:region animated:YES];

然后

activityIndicator =[[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]autorelease];
activityIndicator.frame=CGRectMake(0.0, 0.0, 40.0, 40.0);
activityIndicator.center=self.view.center;
[self.view addSubview:activityIndicator];

if([UIApplication sharedApplication].networkActivityIndicatorVisible=YES)
{

    [activityIndicator startAnimating];

}

然后声明 [activityIndi​​cator stopAnimating]; 在所有操作结束的委托函数处。

于 2012-11-19T11:04:26.653 回答