Reputation: 191
Im creating an app that uses uimap - IOS app . I have created a callout annotation that loads from a nib file and adds it as subview. now i'have added a button in the nib file and I cant get an event when clicking the button in the subview.
how can I make an event when the button in the subview is clicked ?
Thanks.
Upvotes: 0
Views: 206
Reputation: 307
@implementation YourViewController
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
CalloutView *calloutView = however you load it from nib;
calloutView.button.tag = some unique id;
[button addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
return calloutView;
}
- (void)showDetails:(UIButton *)sender
{
NSLog(@"Button tag: %i was pressed", sender.tag);
}
@end
Upvotes: 1