The action is described in mapView:notationView:calloutAccessoryControlTapped:
so that the action is taken when you click the callout now.
-(void)mapView:(MKMapView*)mapViewannouncementView:(MKAnnotationView*)announcementView calloutAccessoryControlTapped:(UIControl*)control{
// processing
}
However, the button type displayed in pin.rightCalloutAccessoryView is
There are only two types of , and they do not appear in UIButtonTypeCustom.
pinView.rightCalloutAccessoryView= UIButtonButtonWithType: UIButtonTypeDetailDisclosure;
How can I put my favorite button in the balloon and calloutAccessoryControlTapped:
ios objective-c mapkit
The frame
is probably zero, so it's actually added, but I can't see it (of course I can't even tap it).
Instead of generating and substituting it directly as it says, you can display the buttons of your choice by setting frame
to change colors or set images if necessary.
UIButton*rightButton=[UIButtonButtonWithType:UIButtonTypeCustom];
rightButton.frame = CGRectMake (0.0, 0.0, 30.0, 30.0); // Specify the appropriate size here
// Also, change colors, set images, do whatever you want...
rightButton.backgroundColor=[UIColor blueColor];
rightButton setImage: UIImage imageNamed:@"flag" forState:UIControlStateNormal;
pinView.rightCalloutAccessoryView=rightButton;
© 2024 OneMinuteCode. All rights reserved.