iPhone注释导致应用程序行动缓慢

时间:2012-02-25 14:56:16

标签: iphone annotations

当我在地图上加载500个注释时,app在移动地图时会变得迟钝,有没有办法解决这个问题? 当地图被缩放并显示50个注释时很好,但是当缩小以显示所有注释时,应用程序很慢并且在地图中移动时会滞后。

当前代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.annotations = [[NSMutableArray alloc] init];

    // Create location manager object
    locationManager = [[CLLocationManager alloc] init];

    // All results from the location manager
    [locationManager setDistanceFilter:kCLDistanceFilterNone];

    // Set accuracy
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

    // Start updating current location
    [mapView setShowsUserLocation:YES];

    self.mapView.mapType = MKMapTypeStandard;   // also MKMapTypeSatellite or MKMapTypeHybrid

    // Start off by default in some city
    MKCoordinateRegion newRegion;
    newRegion.center.latitude = value1;
    newRegion.center.longitude = value2;
    newRegion.span.latitudeDelta = value3;
    newRegion.span.longitudeDelta = value4;

    [self.mapView setRegion:newRegion animated:YES];

    [self.mapView addAnnotations:self.annotations]; // --> self.annotations is array with 500 annotations
}

0 个答案:

没有答案