导航返回上一个视图控制器 [英] Navigate Back to previous view controller

查看:95
本文介绍了导航返回上一个视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 UIView-> UICollectionView-> UICollectionViewCell 。我试图以编程方式返回,但这些都不起作用。代码确实调用了。
我正在使用StoryBoard。

I have a UIView->UICollectionView->UICollectionViewCell. I am trying to navigate back programatically but none of these works. The code did called. I am using StoryBoard.

- (void) goBack:(NSNotification *) notification {
      // [self.navigationController popViewControllerAnimated:YES];
     //  [self dismissViewControllerAnimated:YES completion:nil];
      [self.navigationController popToRootViewControllerAnimated:YES];
}


推荐答案

您需要使用:

[self.navigationController popToRootViewControllerAnimated:YES];

这将带你回到根视图控制器。

This will bring you back to the root view controller.

如果你想导航回以前的视图控制器,你应该实现:

If you want to navigate back to previous view controller, you should implement:

[self.navigationController popViewControllerAnimated:YES];

这篇关于导航返回上一个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆