私はフォーラムを読んでいて、私は同様の問題を見つけることができなかったので、このメッセージを投稿しています。私はタップとダブルタップ(これは標準的なものです)を区別することができる必要がありますが、私の問題は、私が別のScrollView内にスクロールビューを持っている理由が何であれです。そこで、touchedBeginメソッドを呼び出すためにScrollViewをサブクラス化しなければなりませんでした。ScrollView内でシングル/ダブルタップをキャプチャする際の問題
私はPhotoViewController(BaseViewControllerのサブクラス)というクラスがあります。このクラスには、CustomScrollView(ScrollViewのサブクラス)という別のクラスが含まれています。私は、touchesBeginメソッドをオーバーライドし、ユーザーが行ったタッチをキャプチャするために、このCustomScrollViewをScrollViewからサブクラス化する必要がありました。
touchesBeginメソッド内でreturn [super touchesBegan:touches withEvent:event]のようなものを使用してcustomScrollViewからtouchesBeginメソッドを呼び出そうとしましたが、PhotoViewController内のtouchesBeginメソッドが呼び出されたときにパラメータが空です
@class PhotoViewController
@interface PhotoViewController : BaseViewController <UIScrollViewDelegate> {
CustomScrollView* myScrollView;
}
@implementation PhotoViewController
...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
NSUInteger tapCount = [touch tapCount];
switch (tapCount) {
case 1:
[self performSelector:@selector(singleTapMethod) withObject:nil afterDelay:.4];
break;
case 2:
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTapMethod) object:nil];
[self performSelector:@selector(doubleTapMethod) withObject:nil afterDelay:.4];
break;
default:
break;
}
}
クラスCustomScrollViewがある(CustomScrollView.h):ユーザーが、私は必要なものを正確にシングルまたはダブルタップ、)
を作った場合、私はPhotoViewControllerと呼ばれるクラスを、持っている
@interface CustomScrollViewPhoto : UIScrollView {
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
@end
、それは実装がこの(CustomScrollView.m)であるのです。
@implementation CustomScrollViewPhoto
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.superview touchesBegan:[NSSet set] withEvent:event];
return [super touchesBegan:touches withEvent:event];
}
は私が何をしたいのかと間違った方向に行くのだろうか?たぶん、CustomScrollViewクラスのタップ/ダブルタップをキャプチャする必要があります(これはうまくいきます!)、そこから@ Selectorなどを使用してPhotoViewControllerの適切なメソッドを呼び出しますか?
読んでいただきありがとうございます!
こんにちは、それは確かに解決しました! Txs! – nachoman