I have the following methods declared in my app, and I want to implement a switch to turn on and off UILongPressGestureRecognizer in my mapView.
- (IBAction)addNewPin:(UISwitch *)sender {
if (sender.on) {
NSLog(@"ON!!");
}
else {
NSLog(@"OFF!!");
}
}
- (IBAction)didPressForPin:(UILongPressGestureRecognizer *)sender {
CGPoint point = [sender locationInView:self.mapView];
CLLocationCoordinate2D locCoord = [self.mapView convertPoint:point toCoordinateFromView:self.mapView];
MKPointAnnotation *pa = [[MKPointAnnotation alloc]init];
pa.coordinate = locCoord;
pa.title = @"Test Title!";
[mapView addAnnotation:pa];
NSLog(@"Pressed!!");
}
I know that I can add or remove the gesturerecognizer or implement .enabled = NO, but I do not know how to implement it in the switch method.
Something like this can help assuming you have a
longPressGestureRecognizerproperty: