0

私は顧客管理を行い、から継承しUIView、に多くのを追加UIButtonしましたUIView。ユーザーがタッチして移動すると、アニメーションを実行します。関数によってボタンを移動させますtouchesMoved

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

しかし、buttonClickイベントの方が優先度が高いようです。

UITableViewボタンクリックよりもスクロールの方が優先されます。

4

1 に答える 1

1

UIPanGestureRecognizerを調べる必要があります。

これにより、他のハンドラーに送信されたイベントをキャンセルすることができます。


以前のポイントを保護する方法に関する追加情報で更新されました。

アクションコールバックでは、最初のタッチ位置が通知されますrecognizer.state == UIGestureRecognizerStateBegan。このポイントをインスタンス変数として保存できます。また、さまざまな間隔でコールバックを受け取りますrecognizer.state == UIGestureRecognizerStateChanged。この情報を保存することもできます。次に、でコールバックを取得するとrecognizer.state == UIGestureRecognizerStateEnded、インスタンス変数をリセットします。

- (void)handler:(UIPanGestureRecognizer *)recognizer
{
    CGPoint location = [recognizer locationInView:self];
    switch (recognizer.state)
    {
        case UIGestureRecognizerStateBegan:
            self.initialLocation = location;
            self.lastLocation = location;
            break;
        case UIGestureRecognizerStateChanged:
            // Whatever work you need to do.
            // location is the current point.
            // self.lastLocation is the location from the previous call.
            // self.initialLocation is the location when the touch began.

            // NOTE: The last thing to do is set last location for the next time we're called.
            self.lastLocation = location;
            break;
    }
}

お役に立てば幸いです。

于 2012-05-27T13:22:14.543 に答える