ios - Swift Annotation Pin 的 Calloutbubble 手势
问题描述
我正在寻找将手势添加到注释引脚的标注气泡的答案。
我尝试了不同的解决方案,但它们对我不起作用。
这是最新的:
func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView{
let rightButton = UIButton(type: UIButtonType.detailDisclosure)
let gesture = UITapGestureRecognizer(target: self, action: #selector(callout(gesture:)))
rightButton.addGestureRecognizer(gesture)
view.rightCalloutAccessoryView = rightButton
}
@objc func callout(gesture: UITapGestureRecognizer){
print("tapped")
}
解决方案
正确的委托方法
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
///
}
加
self.mapView.delegate = self
推荐阅读
- xaml - Tapgesture 命令 - Xamarin.forms
- apache-spark - Spark Structure Streaming作业在集群模式下失败
- javascript - 导航栏 - 使用 JavaScript 切换活动链接
- c++ - 使用堆栈类计算后缀,C++
- pandas - pypy 7.3.0 (python3.6.9) 中的 Pandas 1.0.1 导入错误
- r - 为什么 dcast 给出 1 和 0?
- java - RecyclerView点击后跳转到顶部
- powershell - 获取使用网络的进程
- mysql - 涉及带条件的部分组的 SQL 查询?
- mysql - 行间时间差