1

指をドラッグするときに距離を見つけてタッチを移動するにはどうすればよいですか。私の指がポイント A から始まり、10 ピクセルのポイント B に移動し、20 ピクセルのポイント A に戻るとします。どうやってそれを計算しますか?

4

5 に答える 5

4
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
 UITouch *touch=[touches anyObject];
point1 = [touch locationInView:self];//(point2 is type of CGPoint)
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
 UITouch *touch=[touches anyObject];
point2 = [touch locationInView:self];//(point2 is type of CGPoint)
}

CGPOint xまたはy軸の差の後、差を得ることができます

于 2012-11-02T06:34:29.627 に答える
0

ユーザーが移動したポイントを追跡できます。の点を記憶し、 でtouchesBegin:距離を累積し、 でtouchesMoved:全体の距離を取得しtouchesEnded:ます。

– touchesBegan:withEvent:
– touchesMoved:withEvent:
- touchesEnded:withEvent:
于 2012-11-02T05:53:02.420 に答える
0

あなたの要件システムのために、デバイス画面からタッチポイントを取得するための主要な3つのデリゲートメソッドを提供します.これらの3つのメソッドは..

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@\"touchesBegan\");// here you can find out A point which user began to touch screen
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@\"touchesMoved\");// here get points of user move finger on screen to start to end point
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@\"touchesEnded\");// here user end touch or remove finger from Device Screen means  (B)
}

これがお役に立てば幸いです...

于 2012-11-02T05:54:29.363 に答える