如何使用滚动操作从子视图控制器中获取父视图控制器?

发布于 2024-12-28 17:35:18 字数 485 浏览 1 评论 0原文

我有两个名为 ViewControllerA 和 ViewControllerB 的 UIViewController。 ViewControllerA 是父类,ViewControllerB 是子类,它是通过 ViewControllerA 类中的 [self.navigationController PushViewController:viewControllerBAnimated:YES]; 来查看的。在 ViewControllerB 类中,我隐藏了 NavigationBar。在按钮操作中,我编码为从 ViewControllerB [self.navigationController popViewControllerAnimated:YES]; 来 ViewControllerA。现在,我想使用交换操作(滚动到上一个屏幕)而不是使用 UIButton 从 ViewControllerB 转到 ViewControllerA。我该怎么做?有人可以给我任何建议或想法吗?提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

节枝 2025-01-04 17:35:19

在子控制器中使用它

- (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 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...

痴梦一场 2025-01-04 17:35:19

您可以尝试在子视图上使用 UISwipeGestureRecognizer 以及执行 [self.navigationController popViewControllerAnimated:YES]; 的处理程序方法。

You can try to use UISwipeGestureRecognizer on your child view with handler method that does the [self.navigationController popViewControllerAnimated:YES];.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文