2012-03-28 7 views
0

Dies ist BridgeAnnotation Schnittstelle, die Delegierten von MKAnnotationHOw Index Klicken particlular Anmerkung Stift zu bekommen in iphone

@interface BridgeAnnotation : NSObject <MKAnnotation> 
{ 

} 
@property(nonatomic,retain) NSString *lat,*lon,*titlevalue,*subtitlevalue; 
@property(nonatomic,assign) NSInteger myindex; 
@end 

ich Wert auf MyIndex Variable setze wie wie unten in meiner Methode

BridgeAnnotation *bridgeAnnotation = [[BridgeAnnotation alloc] init]; 
    [bridgeAnnotation setLat:[@"" stringByAppendingFormat:@"%f",theCoordinate.latitude]]; 
    [bridgeAnnotation setLon:[@"" stringByAppendingFormat:@"%f",theCoordinate.longitude]]; 
    [bridgeAnnotation setTitlevalue:[PMLObj ProductTitle]]; 
    [bridgeAnnotation setSubtitlevalue:[[PMLObj ProductPrice] stringByAppendingFormat:@"$"]]; 
    [bridgeAnnotation setMyindex:i]; 

    [self.mapView addAnnotation:bridgeAnnotation]; 
hat

Das ist mein overiding Methode

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    if ([annotation isKindOfClass:[MKUserLocation class]]) 
     return nil; 


     static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier"; 
     MKPinAnnotationView* pinView = (MKPinAnnotationView *) 
     [mapView dequeueReusableAnnotationViewWithIdentifier:BridgeAnnotationIdentifier]; 
     if (!pinView) 
     { 
      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 


      NSLog(@"---%d",rightButton.tag); 
      [rightButton addTarget:self 
          action:@selector(showDetails:) 
        forControlEvents:UIControlEventTouchUpInside]; 
      customPinView.rightCalloutAccessoryView = rightButton; 

      return customPinView; 
     } 
     else 
     { 
      pinView.annotation = annotation; 
     } 
     return pinView; 


} 

In der obigen Methode möchte ich auf myindex der BridgeAnnotation Klasse zugreifen .. Wie es möglich ist? ODER muss ich andere Methode dafür verwenden ??

Kann mir jemand helfen?

+0

hey Wie werden Sie den Index in 'Brücke Annotation' Einstellung –

Antwort

3

Wenn Sie die Anmerkung auf einen Klick erfassen möchten, dann sollten Sie diesen Delegaten verwenden

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 
{ 
    BridgeAnnotation *annotation = (BridgeAnnotation *)mapView.annotation; 
    NSInteger *yourIndex = annotation.myindex; 
} 
+0

seiner korrekten Index geben danken. – IOSDev

Verwandte Themen