- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的应用程序通过长按来删除引脚,我只允许用户删除两个引脚,我猜它可以工作。但是每次我点击在模拟器中添加一个引脚时,它都会添加两个引脚(不仅仅是一个)。 .这是代码:
-(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/
我是一名优秀的程序员,十分优秀!