UILongPressGestureRecognizer
我在我的应用程序中声明了以下方法,我想在我的 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!!");
}
我知道我可以添加或删除手势识别器或实现.enabled = NO
,但我不知道如何在 switch 方法中实现它。