如何使用MKAnnotationView中的UIActivityIndi​​catorView替换disclosureDetailButton

时间:2012-03-11 06:31:56

标签: iphone ios mkannotationview

我不能用MKAnnotationView中的UIActivityIndi​​catorView替换disclosureDetailButton。

我的代码在这里

-(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];
}

这里是准备segue映射的代码,如果我将spinner分配给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 个答案:

答案 0 :(得分:2)

将微调器分配给aView.rightCalloutAccessoryView。