0

カスタムジェスチャ認識エンジンを作成しています。問題は、reset メソッドが呼び出されないため、認識エンジンの状態をリセットできないことです。その結果、初めてしか機能しません

@implementation TouchGestureRecognizer {

    UIGestureRecognizerState mState;
}

-(UIGestureRecognizerState) state {
    return mState;
}

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    if( [touches count] == 1 ) {
        mState = UIGestureRecognizerStateBegan;
    }
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    if( [touches count] == 1 ) {
        mState = UIGestureRecognizerStateChanged;
    }
}

- (void)reset {
    mState = UIGestureRecognizerStatePossible;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    mState = UIGestureRecognizerStateRecognized;
}

@end
4

2 に答える 2

0

ドキュメントには次のように記載されています。

ジェスチャ認識機能の状態が UIGestureRecognizerStateEnded または UIGestureRecognizerStateRecognized に設定された後、ランタイムはこのメソッドを呼び出します。

でやっていることのようですtouchesEnded:。このメソッドにブレークポイントを置き、そこから取得します。

于 2012-10-25T12:12:59.237 に答える