从导航控制器中解除推送视图 [英] Dismiss pushed view from within Navigation Controller

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

问题描述

我有一个带有View Controller的导航控制器,显示一个按钮。该按钮使用push segue链接到另一个View Controller,后者会自动添加带有后退按钮的顶部导航栏。一切正常。按后退按钮滑出第二个视图并返回到第一个。

I have a Navigation Controller with a View Controller displaying a button. The button is linked to another View Controller using a push segue which automatically adds a top navigation bar with a back button. This all works fine. Pressing the back button slides off the 2nd view and returns to the 1st.

我在第二个视图控制器上有一个按钮,当按下时会运行一些代码和一个委托调用回到第一个视图控制器。再次这样可以正常工作。

I have a button on the 2nd View Controller, that when pressed runs some code and a delegate call back to the 1st View Controller. Again this works fine.

现在我只需要从代码中解除第二个推送的视图,就像按下后退按钮一样。
我尝试过使用dismissModalViewCcontrollerAnimated和dismissViewControllerAnimated,但是它们都会关闭整个导航控制器,它会删除视图2和1(将bak返回到我的主菜单)。

Now I just need to dismiss the 2nd pushed View from code as if the back button was pressed. I have tried using dismissModalViewCcontrollerAnimated and dismissViewControllerAnimated, however they both dismiss the whole Navigation Controller which removes view 2 and 1 (returning bak to my main menu).

什么是从视图中滑出的正确方法。

Whats the correct way to slide off the view.

推荐答案

获取对UINavigationController的引用并调用

Obtain a reference to your UINavigationController and call

- (UIViewController *)popViewControllerAnimated:(BOOL)animated

就可以了。

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

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