mapkit:setSelected(_:动画:)未调用
在“显示映射”页面中,自定义了AnnotationView
,我正在实现中覆盖setSelected(:)
方法。但是,当我点击 AnnotationView
,该方法未调用。
- (void)setSelected:(BOOL)select {
[super setSelected:select];
NSLog(@"select:+++++ %d", select);
}
nslog
不打印,为什么?
In the display map page, the annotationview
is customized and I am overriding thesetSelected(:)
method in the implementation. However, when I clickannotationView
, the method is not called.
- (void)setSelected:(BOOL)select {
[super setSelected:select];
NSLog(@"select:+++++ %d", select);
}
the NSLog
not print, Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接解决方案,
如果您只需要直接解决方案,这可能会有所帮助。
执行
如果是的,我认为您应该覆盖下面的方法,而不是
- (void)setSelected:(bool)选择
,这是 setter 属性的方法选择
。为什么以及如何
经常测试后,我发现
super类
必须将其固化,以便在调用
[super setSelected:select]
时,您将一无所获,这很奇怪,但是如果Apple不建议我们覆盖
selected
's setter 方法- (void)SetSelected :( bool)选择
已经完成了工作。如您所见,此方法存在于大多数系统类中。
Direct Solution
If you only want a direct solution, this may help.
Implementation
If so, I think you should override below method rather than
- (void)setSelected:(BOOL)select
, which is the Setter method of propertyselected
.Why and How
After testing a lot, I find that
Super Class
must implentation thisSo you will get nothing when calling
[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.As you can see, this method exist in the most of System Class.