[英]MapKit : the setSelected(_:animated:) not called
In the display map page, the annotationview
is customized and I am overriding the setSelected(:)
method in the implementation.在显示 map 页面中,
annotationview
视图是自定义的,我在实现中覆盖了setSelected(:)
方法。 However, when I click annotationView
, the method is not called.但是,当我单击
annotationView
时,不会调用该方法。
- (void)setSelected:(BOOL)select {
[super setSelected:select];
NSLog(@"select:+++++ %d", select);
}
the NSLog
not print, Why? NSLog
不打印,为什么?
If you only want a direct solution, this may help.如果您只想要一个直接的解决方案,这可能会有所帮助。
- (void)setSelected:(BOOL)select {
[super setSelected:select animated:YES]
NSLog(@"select:+++++ %d", select);
}
I am overriding the
setSelected(_:animated:)
method in the implementation我在实现中覆盖了
setSelected(_:animated:)
方法
If so, I think you should override below method rather than - (void)setSelected:(BOOL)select
, which is the Setter method of property selected
.如果是这样,我认为您应该覆盖以下方法而不是
- (void)setSelected:(BOOL)select
,这是属性selected
的Setter方法。
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
.... // do your custom work
}
After testing a lot, I find that Super Class
must implentation this经过大量测试,我发现
Super Class
必须实现这个
- (void)setSelected:(BOOL)selected {
}
So you will get nothing when calling [super setSelected:select]
所以调用
[super setSelected:select]
时你什么也得不到
It's weird but may be reasonable If Apple does not recommend us to override selected
's Setter method as - (void)setSelected:(BOOL)select
already do the job.这很奇怪,但可能是合理的如果 Apple 不建议我们将
selected
的Setter方法覆盖为- (void)setSelected:(BOOL)select
已经完成了这项工作。
As you can see, this method exist in the most of System Class.如您所见,这种方法存在于大部分 System Class 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.