更新时间:2022-10-31 12:33:31
在calloutAccessoryControlTapped
委托方法中,使用view.annotation
访问被点击的注释.
In the calloutAccessoryControlTapped
delegate method, use view.annotation
to access the annotation that was tapped.
如果您有一个自定义注释类,则可以对其进行强制转换以方便地访问属性(您可能还需要先检查被点击的注释是否是您感兴趣的类的实例,如果您感兴趣,则很重要使用多个注释类):
If you have a custom annotation class, you can cast it to easily access the properties (you may also want to first check if the annotation tapped is an instance of the class you're interested in--important if you're using multiple annotation classes):
if ([view.annotation isKindOfClass:[TagMark class]]) {
TagMark *tm = (TagMark *)view.annotation;
NSLog(@"tm.someProperty = %@", tm.someProperty);
}