This is BridgeAnnotation interface which has delegate of MKAnnotation
@interface BridgeAnnotation : NSObject <MKAnnotation>
{
}
@property(nonatomic,retain) NSString *lat,*lon,*titlevalue,*subtitlevalue;
@property(nonatomic,assign) NSInteger myindex;
@end
I am setting value to myindex variable in my method like as below
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];
THis is my overiding method
- (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 above method I want to access myindex of BridgeAnnotation class..
How it possible? OR I have to use other method for that??
Can any one help me?
If you want to capture the annotation on a click then you should use this delegate