비동기 요청이 완료된 후 주석 상태에 대한 정보로 사용자 정의 MKAnnotationView
이미지를 업데이트하는 방법을 찾는 데 문제가 있습니다. 후MapKit 업데이트 주석 이미지
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *identifier = @"EstacionEB";
if ([annotation isKindOfClass:[EstacionEB class]]) {
EstacionEB *location = (EstacionEB *) annotation;
CustomPin *annotationView = (CustomPin *) [_mapita dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[CustomPin alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
UIImage * image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png", [location elStatus]]];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.image = image;
NSDictionary *temp = [[NSDictionary alloc]
initWithObjects:[NSArray arrayWithObjects:annotationView, location, nil]
forKeys:[NSArray arrayWithObjects:@"view", @"annotation", nil]
];
//This array is synthesized and inited in my controller's viewDidLoad
[self.markers setObject:temp forKey:location.eid];
return annotationView;
}
return nil;
}
약간, 내가 요청을하고 결과,있는 NSDictionary로, 나는 두 요소에 null를 돌려 다음을 수행하려고 해요 : 지금까지, 나는이이
- (void)updateStation:(NSString *)eid withDetails:(NSDictionary *)details
{
NSInteger free = [details objectForKey:@"free"];
NSInteger parkings = [details objectForKey:@"parkings"];
NSDictionary *storedStations = [self.markers objectForKey:eid];
CustomPin *pin = [storedStations objectForKey:@"view"]; //nil
EstacionEB *station = [referencia objectForKey:@"annotation"]; //nil as well
[station setSubtitle:free];
NSString *status;
if(free==0){
status = @"empty";
} else if((free.intValue>0) && (parkings.intValue<=3) ){
status = @"warning";
} else {
status = @"available";
}
UIImage * image = [UIImage imageNamed:[NSString imageWithFormat:@"%@.png", status]];
pin.image = image;
}
이 (내가 붙여 정확하게 모든 중상 가정) 오류를 제공하지 않지만, NSMutableDictionary 포함해야하는 내 사용자 정의 MKAnnotationView과 MKAnnotation하지만 심지어 내가 요청하기 전에 그들 모두를 로그인 할 때 완료하고 나타나는 모두 올바르게, 언제 요구 est는 마치 MKAnnotationView와 MKAnnotation이 내가 예상했던 것과 다르지 않으므로 완성됩니다. 따라서 주석을 수정하여 이미지를 변경하거나 주석보기를 업데이트 할 수 없습니다.
모든 아이디어를 얻을 수 있습니다.
감사합니다. 나는 당신의 권고를 따르고 나중에 다시보고 할 것입니다. – Roberto
이것은 정확히 내가해야 할 일이다. 정말 고마워! – Roberto