Note that there are some explanatory texts on larger screens.

plurals
  1. PORecognition of swipe with two touches in UIScrollView
    primarykey
    data
    text
    <p>I have an UIScrollView with full screen size (iPad, 1024x768, landscape mode). So I need to recognize swipe with two finger in any direction over it. That's what i have (mainScroll is the property of my class):</p> <pre><code>//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; } </code></pre> <p>and</p> <pre><code>//GestureRecognizer.h - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if ([touches count] &gt; 1) NSLog(@"Started"); } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if ([touches count] &gt; 1) NSLog(@"Moved"); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if ([touches count] &gt; 1) NSLog(@"Ended"); } </code></pre> <p>I had to add condition</p> <pre><code>if ([touches count] &gt; 1) </code></pre> <p>because it works not only for two (ore more) touches, but also for one.</p> <p>But swipe (with two touches) is still scrolls my UIScrollView. How can i prevent it? So how can I recognize swipe without any effect on my scrollView?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload