I have two UIViewController named as ViewControllerA and ViewControllerB
. ViewControllerA is the parent class and ViewControllerB is a child class, it is view by [self.navigationController pushViewController:viewControllerB animated:YES];
from ViewControllerA class. In ViewControllerB class i hidden the NavigationBar. In button action i coded to come ViewControllerA from ViewControllerB [self.navigationController popViewControllerAnimated:YES];
. Now, i want to come ViewControllerA from ViewControllerB using swapping action(Scroll to previous screen) rather than using UIButton. How can i do this? Can anyone please provide me any suggestion or ideas? Thanks in advance.
Use this in child controller
- (void)viewDidLoad
{
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionUp)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
[super viewDidLoad];
}
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
[self.navigationController popViewControllerAnimated:YES];
NSLog(@"Swipe received.");
}
Use Direction as you want..
Happy Coding...