パン ジェスチャ認識エンジンで次のコード行を使用します。
CGPoint translation = [sender translationInView:self.view];
関連する処理を長押しジェスチャ レコグナイザに移動すると、translationInView メソッドがありません。
私の質問は、長押し認識エンジンを使用している場合、どのように翻訳に同じ値を取得できますか?
ありがとう
パン ジェスチャ認識エンジンで次のコード行を使用します。
CGPoint translation = [sender translationInView:self.view];
関連する処理を長押しジェスチャ レコグナイザに移動すると、translationInView メソッドがありません。
私の質問は、長押し認識エンジンを使用している場合、どのように翻訳に同じ値を取得できますか?
ありがとう
お返事をありがとうございます。私が本当に探していたのは、locationInView とは異なる translationInView の計算でした。次のコードでこれを解決しました。
CGPoint location = [sender locationInView:self.view];
CGPoint translation;
translation.x = location.x - viewStartLocation.x;
translation.y = location.y - viewStartLocation.y;
開始位置を追跡する必要がありますが、これはパン ジェスチャ レコグナイザーでは必要ありませんでしたが、うまく機能しているようです。私のコードの残りの部分は、場所ではなく翻訳に集中しているため、一貫性を保つために、他のコードを書き直す必要がないようにしました。
返信にお時間をいただき、重ねてお礼申し上げます。
CGPoint location = [recognizer locationInView:self.view];
UILongPressgestureRecognizerv の場合、ビューでの翻訳ではなく、locationInView です。
-(void)handleLongPress:(UILongPressGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:self.view];
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
break;
case UIGestureRecognizerStateChanged:
break;
case UIGestureRecognizerStateEnded:
break;
default:
break;
}
}
それがあなたを助けることを願っています。