In the display map page, the annotationview
is customized and I am overriding the setSelected(:)
method in the implementation. However, when I click annotationView
, the method is not called.
- (void)setSelected:(BOOL)select {
[super setSelected:select];
NSLog(@"select:+++++ %d", select);
}
the NSLog
not print, Why?
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
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)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
- (void)setSelected:(BOOL)selected {
}
So 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.