我为一个商店制作了一个基于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];
答案 0 :(得分: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];
}
然后声明[activityIndicator stopAnimating];在委托函数中,所有操作都结束。