[英]How to come parent viewcontroller from child viewcontroller by using scrolling action?
I have two UIViewController named as ViewControllerA and ViewControllerB
. 我有两个名为
ViewControllerA and ViewControllerB
UIViewController。 ViewControllerA is the parent class and ViewControllerB is a child class, it is view by [self.navigationController pushViewController:viewControllerB animated:YES];
ViewControllerA是父类,ViewControllerB是子类,通过
[self.navigationController pushViewController:viewControllerB animated:YES];
查看[self.navigationController pushViewController:viewControllerB animated:YES];
from ViewControllerA class. 从ViewControllerA类。 In ViewControllerB class i hidden the NavigationBar.
在ViewControllerB类中,我隐藏了NavigationBar。 In button action i coded to come ViewControllerA from ViewControllerB
[self.navigationController popViewControllerAnimated:YES];
在按钮操作中,我编码为从ViewControllerB到ViewControllerA
[self.navigationController popViewControllerAnimated:YES];
. 。 Now, i want to come ViewControllerA from ViewControllerB using swapping action(Scroll to previous screen) rather than using UIButton.
现在,我想使用交换操作(滚动到上一个屏幕)而不是使用UIButton从ViewControllerB中获取ViewControllerA。 How can i do this?
我怎样才能做到这一点? Can anyone please provide me any suggestion or ideas?
谁能给我任何建议或想法? Thanks in advance.
提前致谢。
You can try to use UISwipeGestureRecognizer
on your child view with handler method that does the [self.navigationController popViewControllerAnimated:YES];
您可以尝试使用具有
[self.navigationController popViewControllerAnimated:YES];
处理程序方法在子视图上使用UISwipeGestureRecognizer
[self.navigationController popViewControllerAnimated:YES];
. 。
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... 快乐编码...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.