我的 View Controller 上有一张 map ,我不知道为什么,但是当我点击注释 View 时,委托(delegate) calloutAccessoryControlTapped
也会被调用,而不仅仅是当我点击细节时关闭。那么为什么会出现这种行为呢?
import UIKit
import MapKit
extension MapVC: MKMapViewDelegate, CLLocationManagerDelegate
{
func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl)
{
...
}
}
最佳答案
根据 Apple 开发者文档:
Accessory views contain custom content and are positioned on either side of the annotation title text. If a view you specify is a descendant of the UIControl class, the map view calls this method as a convenience whenever the user taps your view. You can use this method to respond to taps and perform any actions associated with that control. For example, if your control displayed additional information about the annotation, you could use this method to present a modal panel with that information.
If your custom accessory views are not descendants of the UIControl class, the map view does not call this method.
那么你的accessory view是继承自UIControl的吗?
关于ios - 为什么 calloutAccessoryControlTapped 也会在注释 View 上被调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36432782/