我有一個全屏大小(iPad,1024x768,橫向模式)的UIScrollView。所以我需要用兩根手指在它上面的任何方向識別。這就是我有(mainScroll是我班的財產):礦石UIScrollView滑動識別兩個觸摸
//MyViewController.h
- (void)loadView {
mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
mainScroll.contentSize = CGSizeMake(1024*pageNumber, 768);
mainScroll.pagingEnabled = YES;
mainScroll.delegate = self;
[self.view addSubview:mainScroll];
GestureRecognizer *tapInterceptor = [[GestureRecognizer alloc] init];
tapInterceptor.numberOfTouchesRequired = 2;
tapInterceptor.direction = UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight;
[mainScroll addGestureRecognizer:tapInterceptor];
mainScroll.userInteractionEnabled = YES;
}
和
//GestureRecognizer.h
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] > 1)
NSLog(@"Started");
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] > 1)
NSLog(@"Moved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] > 1)
NSLog(@"Ended");
}
我不得不添加條件
if ([touches count] > 1)
,因爲它的作品不僅爲兩(更多)觸動,但也是一個。
但刷卡(有兩個觸摸)仍然滾動我的UIScrollView。我如何防止它?那麼如何才能識別刷卡而不會對我的scrollView產生任何影響?
哈哈。大聲笑。標題 !! – Legolas
那麼你的編程問題是什麼?請明確點。 – ryanprayogo
問題是:我怎樣才能識別刷卡沒有任何影響我的scrollView? – demon9733