0
有没有办法先加载MapView
然后用注释填充它?MapView加载后从XML加载注释
我之所以问:当我点击我的地图,首先调用我的XML填补了注解,有一个延迟和最后才观与我MapView
开放。
我的担忧是,如果XML增长,它会延迟甚至进一步或超时。
有没有办法先加载MapView
然后用注释填充它?MapView加载后从XML加载注释
我之所以问:当我点击我的地图,首先调用我的XML填补了注解,有一个延迟和最后才观与我MapView
开放。
我的担忧是,如果XML增长,它会延迟甚至进一步或超时。
看到这个代码:在方法,它负载注释使用XML.this会先和一些延迟将开始添加注释后做负载的MapView
#import "MapViewController.h"
#import "MapViewAnnotation.h"
@implementation MapViewController
@synthesize mapView;
// When the view loads
- (void)viewDidLoad
{
[self performSelector:@selector(addAnnotation) withObject:@"" afterDelay:5.0];
}
//here i am delaying my annotation to 5 second so my map can first display
-(void)addAnnotation
{
// Set some coordinates for our position (Buckingham Palace!)
CLLocationCoordinate2D location;
location.latitude = (double) 51.501468;
location.longitude = (double) -0.141596;
// Add the annotation to our map view
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
[newAnnotation release];
}
// When a map annotation point is added, zoom to it (1500 range)
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 1500, 1500);
[mv setRegion:region animated:YES];
[mv selectAnnotation:mp animated:YES];
}
// Received memory warning
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
// If the view unloads, release the map view
- (void)viewDidUnload {
[super viewDidUnload];
[mapView release];
mapView = nil;
}
// Deallocations
- (void)dealloc {
[mapView release];
[super dealloc];
}
@end
放缓。 – Dilip 2013-03-05 06:21:22
@Dilip,谢谢你的回复。你有什么例子吗? – Cliffordwh 2013-03-05 06:23:22
在你的viewDidAppear方法中调用你的xml并保存经纬度数组准备就绪......在按钮上单击添加地图,然后将数组传递给你的viewforannotation委托......这将不需要时间来打开mapview。尝试一下是否有意义。 – BhushanVU 2013-03-05 06:35:20