I customized my MKAnnotationView, when I touch it, it enter following code
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
CellThumbnailView *thumbnailView = (CellThumbnailView *)view;
[mapView setCenterCoordinate:thumbnailView.thumbnail.coordinate animated:YES];
CGSize size = [thumbnailView.thumbnail getThumbnailSize];
thumbnailView.frame = CGRectMake(0, 0, size.width, size.height);
thumbnailView.centerOffset = CGPointMake(0, -[thumbnailView.thumbnail getThumbnailCenterOffset] + size.height / 2);
// Center map at annotation point
thumbnailView.imageView.center = CGPointMake(size.width / 2, size.height/ 2);
thumbnailView.imageView.bounds = CGRectMake(0, 0, size.width, size.height);
thumbnailView.imageView.image = [UIImage imageNamed:[thumbnailView.thumbnail getPopupImageName]];
CGSize labelOffset = [thumbnailView.thumbnail getThumbnailLabelOffset];
thumbnailView.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 45, 20)];
thumbnailView.titleLabel.backgroundColor = [UIColor clearColor];
thumbnailView.titleLabel.textColor = [UIColor blueColor];
thumbnailView.titleLabel.shadowColor = [UIColor colorWithWhite:1 alpha:0.5];
thumbnailView.titleLabel.shadowOffset = CGSizeMake(0, -1);
thumbnailView.titleLabel.font = [UIFont boldSystemFontOfSize:17];
thumbnailView.titleLabel.alpha = 1;
thumbnailView.titleLabel.minimumScaleFactor = .8f;
thumbnailView.titleLabel.adjustsFontSizeToFitWidth = YES;
thumbnailView.titleLabel.center = CGPointMake(thumbnailView.center.x - labelOffset.width, thumbnailView.center.y - labelOffset.height);
thumbnailView.titleLabel.text = [NSString stringWithFormat:@"%dG", thumbnailView.thumbnail.traffic];
[thumbnailView addSubview:thumbnailView.titleLabel];
self.location.text = thumbnailView.thumbnail.desc;
self.traffic.text = thumbnailView.titleLabel.text;
self.reportView.hidden = NO;
}
If you notice this:
thumbnailView.frame = CGRectMake(0, 0, size.width, size.height);
It means I want to change my thumbnail to a big one, so I changed frame.
But with this frame change, when I touch the view, it disappears.
But after I zoom it in or out, it shows again.
The strange thing is: when I remove that frame change, the problem is gone.
I want to know why and how to solve this problem (I still need change frame if possible).