Как заменить DisclosureDetailButton на UIActivityIndicatorView в MKAnnotationView - PullRequest
0 голосов
/ 11 марта 2012

Я не могу заменить disclosureDetailButton на UIActivityIndicatorView в MKAnnotationView.

Мой код здесь

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)aView 
    calloutAccessoryControlTapped:(UIControl *)control
{
      UIActivityIndicatorView * spinner = [[UIActivityIndicatorView alloc] 
          initWithFrame:CGRectMake(0, 0, 31, 31)];
      [spinner startAnimating];
      [aView addSubview:spinner]; 
      [self performSegueWithIdentifier:@"photoMap" sender:self];
}

вот код, который готовится к переходу к карте, если яназначить спиннер для annoView.rightCalloutAccessoryView, это приведет к сбою

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
  if ([segue.identifier isEqualToString:@"photoMap"]) 
 {
       NSLog(@"the value is %i",(int)self.annotationValue);
       UIActivityIndicatorView * spinner = [[UIActivityIndicatorView alloc]     initWithFrame:CGRectMake(0, 0, 31, 31)];
       [spinner startAnimating];

       MKPinAnnotationView * annoView = [self.annotations objectAtIndex:(NSUInteger)self.annotationValue];
       annoView.rightCalloutAccessoryView = spinner;//crash here!!!!!
       SecViewController *newVC = segue.destinationViewController;
       dispatch_queue_t  downloadQueue = dispatch_queue_create("photos downloader", NULL);
       dispatch_async(downloadQueue, ^{
       NSArray *photos =  [FlickrFetcher photosInPlace:[self.places objectAtIndex: (NSUInteger)self.annotationValue]  maxResults:50];
        dispatch_async(dispatch_get_main_queue(), ^{
         [newVC setPhotos:photos];
         [newVC setAnnotationValue:self.annotationValue];
         [newVC setPlaces:self.places];
         newVC.delegate = self;
          });
     });
     dispatch_release(downloadQueue);
  }

}

1 Ответ

2 голосов
/ 11 марта 2012

Назначьте счетчик aView.rightCalloutAccessoryView.

...