Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone simulator swipe right works, but swipe left does not?

I'm trying to use swipe left and right on a UIScrollView. However it looks like swipe left does not work in iPhone simulator even though swipe right does. Did I miss any step?

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    self.scrollView.multipleTouchEnabled = YES;
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
    swipe.delaysTouchesBegan = YES;
    swipe.numberOfTouchesRequired = 2;
    [self.scrollView addGestureRecognizer:swipe];
    [swipe release];
}

- (void)handleSwipe:(UISwipeGestureRecognizer *)recognizer
{
    if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {

    } else if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {

    }
}
like image 945
Guoliang Cao Avatar asked Jul 05 '11 03:07

Guoliang Cao


People also ask

How do you swipe in iOS simulator?

1- Place the pointer at the start position. 2- Hold the mouse button. 3- Move the pointer in the swipe direction and release the mouse button.

Can you turn off the swipe left on iPhone?

Swipe left opens the camera, That cannot be disabled.


1 Answers

Use Following:

UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];
[mainSlideShowImageScrollView addGestureRecognizer:rightRecognizer];
[rightRecognizer release];
UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[leftRecognizer setNumberOfTouchesRequired:1];
[mainSlideShowImageScrollView addGestureRecognizer:leftRecognizer];
[leftRecognizer release];   



- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer 
   {
      //Do moving
   }

- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer 
{
  // do moving
}
like image 197
rptwsthi Avatar answered Sep 21 '22 17:09

rptwsthi