2012-03-11 12 views
0

MKAnnotationViewのdisclosureDetailButtonをUIActivityIndi​​catorViewに置き換えることはできません。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]; 
} 

である私は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); 
    } 

}

+0

*コードのブロック*は、4つのスペースでインデントする必要があります。バッククォートは、コードの*インライン*スニペット用です。 –

+0

私は新しい、gocha、thx – user1250152

答えて

2

スピナーをaView.rightCalloutAccessoryViewに割り当てます。

+0

がうまくいかなかった、私はスレッドに入れていない、それは重要ですか? – user1250152

+0

私はそれがうまくいくと思います。あなたが試みたコードを投稿してください。 –

+0

上に自分のコードを追加しました – user1250152

関連する問題