相关疑难解决方法(0)

UITapGestureRecognizer - 让它在降落时工作,而不是修饰?

我正在使用tap事件是非常时间敏感的,所以我很好奇是否有可能在用户简单触摸时激活UITapGestureRecognizer,而不是要求它们也能触摸起来?

objective-c ios uitapgesturerecognizer swift

78
推荐指数
3
解决办法
5万
查看次数

UITouch移动速度检测

我试图检测触摸运动的速度,我并不总是得到我期望的结果.(补充说:速度太快了)如果我正在做一些时髦或建议更好的方法,有人能发现吗?


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    self.previousTimestamp = event.timestamp;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];
    CGPoint prevLocation = [touch previousLocationInView:self.view];
    CGFloat distanceFromPrevious = distanceBetweenPoints(location,prevLocation);
    NSTimeInterval timeSincePrevious = event.timestamp - self.previousTimestamp;
    CGFloat speed = distanceFromPrevious/timeSincePrevious;
    self.previousTimestamp = event.timestamp;
    NSLog(@"dist %f | time %f | speed %f",distanceFromPrevious, timeSincePrevious, speed);

}

Run Code Online (Sandbox Code Playgroud)

iphone objective-c

11
推荐指数
1
解决办法
8682
查看次数

标签 统计

objective-c ×2

ios ×1

iphone ×1

swift ×1

uitapgesturerecognizer ×1