首先在MKMapView中只有用户位置。一些行动后,我打电话方法: [self mapView:self.mapView didAddAnnotationViews:self.pointersArray];
我didAddAnnotationViews
方法:MKMapView应用程序在使用缩放后崩溃
-(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
if (views.count == 1) {
MKAnnotationView *annotationView = [views objectAtIndex:0];
id<MKAnnotation>mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 500, 500);
[mapView setRegion:region animated:YES];
}
else {
[mapView addAnnotations:views];
}
}
应用程序没有崩溃,直到不使用变焦。但是当缩放使用超过10次(约)时,我在这个[mapView addAnnotations:views];
或有时在return UIApplicationMain(argc, argv, nil, NSStringFromClass([BIDAppDelegate class]));
中出错。错误 - EXC_BAD_ACCESS
。有我的问题?
编辑
更改为[self.mapView setRegion:region animated:YES];
但现在我在主线程MKNormalizedPointForLayer EXC_BAD_ACCESS
错误。在通常的变焦工作,使用变焦例如7次以上的应用程序崩溃.. 我的按钮的动作:
- (void)showKantorsOnMap {
if (self.kantorsData.count != self.pointersArray.count) {
NSLog(@"need to wait more");
}
NSMutableArray *toRemove = [[NSMutableArray alloc] init];
for (id annotation in self.mapView.annotations)
if (annotation != self.mapView.userLocation)
[toRemove addObject:annotation];
[self.mapView removeAnnotations:toRemove];
[self.mapView addAnnotations:self.pointersArray];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(self.mapView.userLocation.coordinate,6500, 6500);
[self.mapView setRegion:region animated:YES];
}
SOLUTION 问题是didAddAnnotationViews
方法[mapView addAnnotations:views];
称为递归。
你会说俄语吗?) – RomanHouse 2012-07-09 15:16:12
不,不幸的不是。 – Anna 2012-07-09 15:29:01
对不起,基于您的昵称:)。我编辑了我的问题。也许需要另一个我的代码? – RomanHouse 2012-07-09 15:37:03