gpt4 book ai didi

iphone - 长按每次轻按会掉落 2 个引脚

转载 作者:行者123 更新时间:2023-12-03 20:46:38 27 4
gpt4 key购买 nike

我的应用程序通过长按来删除引脚,我只允许用户删除两个引脚,我猜它可以工作。但是每次我点击在模拟器中添加一个引脚时,它都会添加两个引脚(不仅仅是一个)。 .这是代码:

-(void) handleLongPressGesture:(UIGestureRecognizer*)sender
{
if (pinId < 3) {
// Here we get the CGPoint for the touch and convert it to
// latitude and longitude coordinates to display on the map

CGPoint point = [sender locationInView:self.mapView];
CLLocationCoordinate2D coord = [self.mapView convertPoint:point
toCoordinateFromView:self.mapView];

if (pinId == 1) {
lat1 = coord.latitude;
long1 = coord.longitude;

MapAppAnnotation* annotation;
annotation = [[MapAppAnnotation alloc] initWithCoordinate:coord
andID:pinId];

[mapView addAnnotation:annotation];

MKCircle* circle = [MKCircle circleWithCenterCoordinate:coord
radius:5000];
[mapView addOverlay:circle];
pinId++;

} else {
lat2 = coord.latitude;
long2 = coord.longitude;
MapAppAnnotation* annotation2;
annotation2 = [[MapAppAnnotation alloc] initWithCoordinate:coord
andID:pinId];

[mapView addAnnotation:annotation2];
}
}
}

我想知道是否是我的错(代码错误..)或者是iPhone模拟器让我的长鼠标压力像两个不同的长压力..这可能吗?

最佳答案

当手势开始时,您的选择器将被调用一次,当手势结束时,您的选择器将被调用一次。检查手势的状态并对相关手势进行操作。

-(void)handleLongPressGesture:(UIGestureRecognizer*)sender
{
if (sender.state != UIGestureRecognizerStateEnded) return;

// otherwise, handle the gesture as before
}

UILongPressGestureRecognizer 的类引用说:

Long-press gestures are continuous. The gesture begins (UIGestureRecognizerStateBegan) when the number of allowable fingers (numberOfTouchesRequired) have been pressed for the specified period (minimumPressDuration) and the touches do not move beyond the allowable range of movement (allowableMovement). The gesture recognizer transitions to the Change state whenever a finger moves, and it ends (UIGestureRecognizerStateEnded) when any of the fingers are lifted.

关于iphone - 长按每次轻按会掉落 2 个引脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5564437/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com