我有一個mapkit應用程序,它可以在地圖上放置註釋,當你按下它時,它會顯示標題屬性的標註。ios mapkit通過點擊地圖關閉註釋標註
這工作正常,但用戶無法關閉它們。他們保持開放狀態,直到他們再次註釋爲止。我不能讓用戶點擊地圖上的其他地方(或再次點擊註釋)關閉它嗎?
我有一種感覺,這是默認設置,所以也許我正在做的東西是填塞它?我有我用它來檢測一些地圖水龍頭
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleTap:)];
tap.numberOfTapsRequired = 1;
[self.mapView addGestureRecognizer: tap];
它將觸發該手勢識別:
- (void)handleTap:(UITapGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateEnded) {
CGPoint tapPoint = [sender locationInView:sender.view.superview];
CLLocationCoordinate2D coordinate = [self.mapView convertPoint: tapPoint toCoordinateFromView: self.mapView];
if (pitStopMode && !pitStopMade){
pitStopMade = YES;
InfoAnnotation *annotation = [[InfoAnnotation alloc]
initNewPitstopWithCoordinate:coordinate];
NSLog(@" Created Pit Stop");
annotation.draggable = NO;
//place it on the map
[self.mapView addAnnotation: annotation];
self.instructionLabel.text = @"Tap button again to remove";
annotation.creatorId = self.localUser.deviceId;
//send it to the server
[annotation updateLocationWithServerForConvoy: self.convoyCode];
[annotation release];
}
if (hazardMode && !hazardMade){
hazardMade = YES;
InfoAnnotation *annotation = [[InfoAnnotation alloc]
initNewHazardWithCoordinate:coordinate];
NSLog(@" Created Hazard");
annotation.draggable = NO;
//place it on the map
[self.mapView addAnnotation: annotation];
self.instructionLabel.text = @"Tap button again to remove";
annotation.creatorId = self.localUser.deviceId;
//send it to the server
[annotation updateLocationWithServerForConvoy: self.convoyCode];
[annotation release];
}
}
}
有什麼我必須做的,也讓這些水龍頭經歷到mapview?在註釋上拖動和點擊效果很好,但我不確定這是什麼原因造成的?
有沒有我缺少的選項,還是我必須嘗試手動實現這個?