I want to set the tag in DetailDisclosure
button in objective c. My old code is:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if (annotation == mapView.userLocation)
{
return nil;
}
else
{
static NSString * const identifier = @"MyCustomAnnotation";
static int i;
MKAnnotationView* annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView)
{
annotationView.annotation = annotation;
}
else
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:identifier];
}
NSLog(@"%i",annotationView.tag);
annotationView.tag=annotationView.tag+1;
NSLog(@"%i",annotationView.tag);
annotationView.image = [UIImage imageNamed:@"pin1.png"];
annotationView.canShowCallout = YES;
UIImageView *sfIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"newlocation.png"]];
annotationView.leftCalloutAccessoryView = sfIconView;
UIButton *InformationButton=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[InformationButton addTarget:self action:@selector(annotationButtClicked:) forControlEvents:UIControlEventTouchUpInside];
InformationButton.tag=i;
annotationView.rightCalloutAccessoryView=InformationButton;
UILongPressGestureRecognizer *longGesture=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(LongPressEvent:)];
[annotationView addGestureRecognizer:longGesture];
return annotationView;
}
}
Function Implementation
- (void)annotationButtClicked:(id)sender
{
NSLog(@"%i",[sender tag]);
}
Console Output is Every time 0.
How do I set the tag in DetailDisclosure
?