mapview에 여러 개의 주석 (arround 500)을 추가하고 싶지만 표시되는 최대 값은 100입니다. 100을 넘으면 viewForAnnotation 대리자 메서드가 호출되지 않습니다. 그러나 여기에 100MKMapView에서 그릴 수있는 주석 (MKAnnotation)의 최대 개수는 무엇입니까?
아래 주석 완벽하게 작동 코드이다 : (에만 작동 annotationArray 어레이의 수가 적은 (101)를 초과 할 때)
_allPoints = [[NSMutableArray alloc] init];
NSString* responseFile = [[NSBundle mainBundle] pathForResource:@"Datafile" ofType:@"txt"];
NSData *sampleData = [NSData dataWithContentsOfFile:responseFile];
if (sampleData) {
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:sampleData
options:kNilOptions
error:&error];
NSArray* response = [json objectForKey:@"response"];
for (NSDictionary *lineDict in response) {
if ([[lineDict objectForKey:@"data"] isKindOfClass:[NSArray class]]) {
SinglePoint *singlePoint = [[SinglePoint alloc] initWithDictionary:lineDict];
[_allPoints addObject:singlePoint];
}
else {
NSLog(@"Error");
}
}
}
_mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[_mapView setDelegate:self];
[self.view addSubview:_mapView];
NSMutableArray *annotationArray = [[NSMutableArray alloc] init];
for (int i=0; i<[_allPoints count]; i++) {
SinglePoint *singlePoint = [_allPoints objectAtIndex:i];
NVPolylineAnnotation *annotation = [[NVPolylineAnnotation alloc] initWithPoint:singlePoint mapView:_mapView];
[annotationArray addObject:annotation];
}
[_mapView addAnnotations:(NSArray *)annotationArray];
CLLocationCoordinate2D centerCoord = { 28.632747, 77.219982 };
[_mapView setCenterCoordinate:centerCoord zoomLevel:12 animated:NO];
위임 방법이다
편집 : 의견 당, 재사용 시작했지만 행운을 빌어 요. (
if ([annotation isKindOfClass:[NVPolylineAnnotation class]]) {
static NSString *viewIdentifier = @"annotationView";
NVPolylineAnnotationView *annotationView = (NVPolylineAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:viewIdentifier];
if (annotationView == nil) {
annotationView = [[NVPolylineAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:viewIdentifier mapView:_mapView];
}
return annotationView;
}
return nil;
설명서 또는 그 밖의 다른 곳에서는 제한을 찾을 수 없습니다. 메모리 문제일까요?
당신이 당신의'annotationArray'에'allPoints' 500 회에서 첫 번째 개체를 추가하면 어떻게됩니까? –
'NVPolylineAnnotation'에 대한 소스 코드를 제공 할 수 있습니까? –