我试图在长按后获得该位置以在该位置周围放置一个覆盖层。但是,我在长按上设置的动作没有触发。
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
//add the long press options
//single finger long press
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(getMapCoordinateFromTouch:)];
[longPressGesture setNumberOfTouchesRequired:1];
longPressGesture.delegate = self;
[self.mapview addGestureRecognizer:longPressGesture];
//double finger long press
UILongPressGestureRecognizer *doubleLongPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(removeBoundry:)];
[doubleLongPressGesture setNumberOfTouchesRequired:2];
doubleLongPressGesture.delegate = self;
[self.mapview addGestureRecognizer:doubleLongPressGesture];
这是它调用的函数
-(void)getMapCoordinateFromTouch:(UILongPressGestureRecognizer *) gesture{
if(gesture.state == UIGestureRecognizerStateBegan){
CGPoint touchlocation = [gesture locationInView:self.mapview];
pressedloc = [self.mapview convertPoint:touchlocation toCoordinateFromView:self.mapview];
[self createBundarywithRadius:.1];
}