- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我已经设置了一个 UISwipeGestureRecognizer
:
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:delegate action:@selector(handleSwipeGesture:)];
swipe.direction = UISwipeGestureRecognizerDirectionUp;
[self addGestureRecognizer:swipe];
[swipe release];
滑动使玩家向滑动的方向移动。不过,我需要玩家继续移动,直到进行滑动的手指离开屏幕。我试过使用 touchesEnded: 方法,但它要求先进行非滑动触摸。我怎样才能得到做出滑动手势的触摸?如何检测该触摸何时离开屏幕?
最佳答案
我知道您已经对这个问题的答案感到满意,但我想我可能会推荐使用 UIPanGestureRecognizer 而不是滑动手势。
使用平移手势识别器,消息会重复发送到选择器,直到用户停止拖动他们的手指,此时再次调用选择器,传递 gesture.state
UIGestureRecognizerStateEnded
。示例:
- (void)panGesture:(UIPanGestureRecognizer *)gesture {
if (gesture.state == UIGestureRecognizerStateEnded) {
CGPoint translation = [gesture translationInView:self.view];
//This contains the total translation of the touch from when it
//first recognized the gesture until now.
//
//e.g (5, -100) would mean the touch dragged to the right 5 points,
//and up 100 points.
}
}
关于iphone - 在 UISwipeGesture[Recognizer] 之后检测手指何时抬起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3427280/
我用 cocos2d 制作了我的第一个应用程序,所以我在这里很新 我的第一个问题: 我不会让物体(船)跟随我的手指。 -(void) ccTouchMoved:(UITouch *)touch wit
如果某人将右手压在扫描仪的玻璃上进行扫描,结果将如下所示: (没有橙色和白色注释)。我们如何确定某人的 2D:4D ratio从他们的手的图像? 最佳答案 您已经标记了这个很棒的 opencv - 我
我的 View Controller 中有几个 UIScrollView。我想覆盖一个通过 UIPanGestureRecognizer 捕获 2 根手指滑动的 View ,它不会记录 UIScrol
现在这真是令人困惑...在不离开页面的情况下更新 mysql 数据库...我有 3 位代码。 head 标签中的 javascript、body 中的操作按钮以及要在另一个页面上执行的代码。以下是三个
我有这段代码是从 Style clipboard in flutter 得到的 showMenu( context: context, // TODO: Positio
我是一名优秀的程序员,十分优秀!