任何人都知道是否有办法从button添加的点击事件中获取MKAnnotationView,这button被用作标签只是为了显示每个图钉的名称map,现在我成功地显示了一个自定义view(包含图像,文本.... )pin单击时,我需要在单击按钮(标签)时执行相同的操作.
感谢您提供的任何建议.
为代码button在MKAnnotationView:
UIButton * pinButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 140, 28)];
[pinButton.titleLabel setTextColor:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1]];
[pinButton setCenter:CGPointMake(pinAnnotationView.center.x + 70, pinAnnotationView.center.y + 10)];
[pinButton addTarget:self action:@selector(pinLabelClicked) forControlEvents:UIControlEventTouchUpInside];
[pinAnnotationView addSubView:pinButton];
[pinButton setUserInteractionEnabled:YES];
Run Code Online (Sandbox Code Playgroud)