0

カスタムUIButtonを実装し、LongPressイベントを(Gesture Recognizersを使用せずに)処理するために、クラスでを使用する必要touchesBegan:がありました。touchesEnded:問題は、通常のボタンイベントが機能していないことです。何が原因で、どうすれば回避できるのでしょうか。

タッチベースのイベントは機能していますが、以前のアクションはtouchUpInside:機能しなくなりました。

ありがとう

4

1 に答える 1

1

長押しには使用しないtouchesBegan:でください。このジェスチャレコグナイザーを使用してください。

UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]     initWithTarget:self action:@selector(longTap:)];
[view addGestureRecognizer:longPressGesture];
[longPressGesture release];

-(void) longTap:(UILongPressGestureRecognizer *)gestureRecognizer{
    NSLog(@"gestureRecognizer= %@",gestureRecognizer);
    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
        NSLog(@"longTap began");
    } 
}
于 2012-03-16T14:43:53.560 に答える