Mam aplikację mapkit, która umieszcza adnotacje na mapie, po ich naciśnięciu pokazuje objaśnienie z atrybutem title.ios mapkit zamykanie objaśnień opisów przez dotknięcie mapy
Działa to dobrze, ale użytkownik nie może ich zamknąć. Pozostają otwarte, dopóki nie dotkną kolejnej adnotacji. Czy nie mogę zrobić tego, aby użytkownik mógł dotknąć innego użytkownika na mapie (lub ponownie dotknąć adnotacji), aby ją zamknąć?
Miałem przeczucie, że to ustawienie domyślne, więc może coś, co robię, napycha? Mam rozpoznawania gestów, które używam do wykrywania niektórych map krany
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleTap:)];
tap.numberOfTapsRequired = 1;
[self.mapView addGestureRecognizer: tap];
który odpala to:
- (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];
}
}
}
Czy jest coś, co muszę zrobić, aby także niech te zawory przechodzą do widoku mapy? Przeciąganie i stukanie w adnotacje działa dobrze, więc nie jestem pewien, czy to jest przyczyną tego problemu?
jest opcja, której mi brakuje, czy muszę spróbować ją wdrożyć ręcznie?