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.
Asked
Active
Viewed 243 times
2

Yuvaraj.M
- 9,741
- 16
- 71
- 100
2 Answers
2
You can try to use UISwipeGestureRecognizer
on your child view with handler method that does the [self.navigationController popViewControllerAnimated:YES];
.

Kyr Dunenkoff
- 8,090
- 3
- 23
- 21
2
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...

Mehul Mistri
- 15,037
- 14
- 70
- 94