In my project, i have two views. One is homeViewController and other is searchViewController. I have done right swipe gesture on homeViewController to show searchViewController. But UISwipeGestureRecognizerDirectionRight doesn’t work for me. It gives left animation rather than right.
I have added below code in homeViewController.m to add gesture property and show SearchViewController:
UISwipeGestureRecognizer *swipeRecognizer=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDetected:)];
[swipeRecognizer setDirection:UISwipeGestureRecognizerDirectionRight];
[self.view addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
-(void)swipeDetected:(UIGestureRecognizer *)sender
{
SearchViewController *searchView=[[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
[self.navigationController pushViewController:searchView animated:YES];
[searchView release];
}
Please help me out.
Thanks.
The animation here is coming as part of the navigation controllers
pushViewController:animated:method, it has nothing to do with the direction of the gesture recognizer (that only determines which way the user needs to swipe in order for the swipe to be recogized)if you want to be able to swipe between view controllers in other directions you could look at UIPageViewController