포럼을 읽었으며 비슷한 문제를 찾을 수 없어이 메시지를 게시하고 있습니다. 나는 탭핑과 두 번 두드리기를 할 수 있어야한다. (이것은 표준적인 것이다.) 그러나 내 문제는 어떤 이유로 든 다른 ScrollView 내부에 스크롤 뷰가 있다는 것이다. 그래서 touchedBegin 메서드를 호출하기 위해 ScrollView를 하위 클래스에 추가해야했습니다.ScrollView 내부에서 싱글/더블 탭 캡쳐 문제
나는 PhotoViewController (BaseViewController의 하위 클래스)라는 클래스가 있는데이 클래스에는 CustomScrollView (ScrollView의 하위 클래스)라는 또 다른 클래스가 포함되어 있습니다. touchesBegin 메서드를 재정의하고 사용자가 만든 터치를 캡처 할 수 있도록이 CustomScrollView를 ScrollView에서 하위 클래스로 분류해야했습니다. [: withEvent 만지는 : 슈퍼 touchesBegan 이벤트]
나는 반환 같은 것을 사용 CustomScrollView에서 touchesBegin 메소드를 호출 시도 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