Nhiệm vụ của tôi là bỏ chọn chú thích bản đồ trên lần nhấn thứ hai.Cách bỏ chọn chú thích bản đồ trên lần nhấn thứ hai
Tôi không tìm thấy cách thực hiện với chức năng mapView. Vì vậy, tôi đã sử dụng một bài viết từ stackoverflow và làm như thế này:
- (void)viewDidLoad
{
annotationTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(annotationTapRecognized:)];
annotationTap.numberOfTapsRequired = 1;
annotationTap.delegate = self;
}
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
[view addGestureRecognizer:annotationTap];
}
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
[view removeGestureRecognizer:annotationTap];
}
- (void)annotationTapRecognized:(UIGestureRecognizer *)gesture
{
NSArray *selectedAnnotations = self.viewMap.selectedAnnotations;
for (MapAnnotation *annotationView in selectedAnnotations) {
[self.viewMap deselectAnnotation:annotationView animated:NO];
}
}
Có vẻ như nó hoạt động chính xác, nhưng không phải vậy. Khi tôi nhấn vào chú thích thứ hai chú thích thời gian biến mất và xuất hiện một lần nữa.
Bất kỳ ý tưởng nào?
Xin cảm ơn trước.
Nhưng tôi đã thêm thông tin này ở đâu? Tôi đã nghĩ về điều này. Nhưng làm cách nào tôi có thể cấm hiển thị chú dẫn khi nhấp chuột? Cảm ơn. – Igor