I have two info buttons showing up within my callout view for some reason. I have 3 different pin colors that are pulling information from 3 different sources. I need each button for each pin color to push to a separate view controller based on that annotation class. i have the following code so far for my 3 different pin colors:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if([annotation isKindOfClass:[MKUserLocation class]]) {
return nil;
}
static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[annotation class]]) {
MKPinAnnotationView *view = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (view == nil) {
view = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:identifier];
} else {
view.annotation = annotation;
}
if([[(Annotation*)annotation phoneNumber] isEqualToString:@"0"]){
view.enabled = YES;
view.canShowCallout = YES;
view.pinColor = MKPinAnnotationColorPurple;
// Create a UIButton object to add on the
self.leftBtn = [UIButton buttonWithType:UIButtonTypeInfoDark];
[self.leftBtn setTitle:annotation.title forState:UIControlStateNormal];
[view setLeftCalloutAccessoryView:self.leftBtn];
}else{
view.enabled = YES;
view.canShowCallout = YES;
// Create a UIButton object to add on the
self.rightBtn = [UIButton buttonWithType:UIButtonTypeInfoDark];
[self.rightBtn setTitle:annotation.title forState:UIControlStateNormal];
[view setRightCalloutAccessoryView:self.rightBtn];
}
if ([[(Annotation*)annotation phoneNumber] isEqualToString:@"1"]){
view.enabled = YES;
view.canShowCallout = YES;
view.pinColor = MKPinAnnotationColorGreen;
// Create a UIButton object to add on the
self.leftBtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[self.leftBtn setTitle:annotation.title forState:UIControlStateNormal];
[view setLeftCalloutAccessoryView:self.leftBtn];
}
return view;
}
return nil;
}
And for my accessory tapped method I have the following:
- (void)mapView:(MKMapView *)map annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
if(view.leftCalloutAccessoryView){
UserAnnotation *annotate = view.annotation;
BuydealsViewController *dealsView=[[BuydealsViewController alloc]initWithNibName:@"DealDetailsViewViewController" bundle:[NSBundle mainBundle]];
dealsView.urlString = annotate.url;
[self.navigationController pushViewController:dealsView animated:YES];
}
if(view.rightCalloutAccessoryView){
MapDealViewController *mapDeals = [[MapDealViewController alloc] init];
Annotation *annView = view.annotation;
mapDeals.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
mapDeals.phoneNumber = annView.phoneNumber;
mapDeals.address = annView.subtitle;
mapDeals.title = annView.title;
mapDeals.description = annView.description;
mapDeals.value = annView.value1;
mapDeals.discountPercent = annView.discountPercent;
mapDeals.price = annView.price;
mapDeals.header = annView.header;
mapDeals.imageUrl = annView.imageUrl;
mapDeals.url = annView.url;
mapDeals.dealy = annView.dealy;
self.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:mapDeals animated:YES];
}
}
Is there any way to make them both right buttons but click to separate views?