I am currently writting an ios5 app and call two functions (back) and (next) with buttons. I would like to call them with swipe gestures instead.
Would that be possible and how?
Thanks
I am currently writting an ios5 app and call two functions (back) and (next) with buttons. I would like to call them with swipe gestures instead.
Would that be possible and how?
Thanks
Use swipe gesture for both right direction (next button) and left direction (back button) For left direction:
UISwipeGestureRecognizer *swipeLeft =[[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(didSwipeLeft:)];
swipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;
swipeLeft.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeLeft];
[swipeLeft release];
For right direction:
UISwipeGestureRecognizer *swipeRight =[[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(didSwipeRight:)];
swipeRight .direction=UISwipeGestureRecognizerDirectionRight;
swipeRight .numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeRight ];
[swipeRight release];
You handle them with events:
-(void)didSwipeRight
{
//For right direction (next button)
}
-(void)didSwipeLeft
{
//For left direction (back button)
}