简体   繁体   English

iOS触控:快速和慢速触控移动

[英]iOS touch : fast and slow touch move

I'm trying to make touch mouse using iPhone. 我正在尝试使用iPhone制作触摸鼠标。 I want know how to make different slow move and fast move. 我想知道如何做出不同的慢动作和快动作。 I want make the cursor on PC move far when I move touch fast on iPhone. 当我在iPhone上快速移动触摸时,我希望使PC上的光标移动得更远。 Currently, mine move same distance(pixels) for both slow and fast. 目前,我的慢速和快移相同的距离(像素)。 Some velocity is required. 需要一定的速度。 Is there any simple idea or proper framework? 有没有简单的想法或适当的框架?

I'm assuming you're already using a pan gesture recognizer, or at least know how to hook one up for this. 我假设您已经在使用平移手势识别器,或者至少知道如何为此使用一个手势识别器。 If you do that, you can get velocity this way: 如果这样做,则可以通过以下方式获得速度:

- (void) handlePan:(UIPanGestureRecognizer *)pan {
    CGPoint velocity = [pan velocityInView:self.view];
    NSLog(@"Horizontal velocity: %f", velocity.x);
    NSLog(@"Vertical velocity: %f", velocity.y);
}

Velocity is returned as a CGPoint where the x value represents horizontal velocity and the y value represents vertical velocity. 速度作为CGPoint返回,其中x值表示水平速度, y值表示垂直速度。 The further the value is from 0, the faster it is. 值离0越远,则速度越快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM