简体   繁体   English

我如何退回segue?

[英]How do I unwind a segue back?

I've looked through numerous answers and tried everything (it seems), but I still cannot get my unwind to work. 我已经浏览了许多答案并尝试了所有方法(看来),但仍然无法放松自己的精力。

I have as a storyboard sequence: 我有一个故事板序列:

Nav Controller -> Main Interface Controller -> Nav Controller -> City Selection Table View Controller. 导航控制器->主界面控制器->导航控制器->城市选择表视图控制器。

I've added a bar button to function as a back button in my City Selection Table View Controller to go back to the Main Interface, and linked it to the exit, but it still is not working. 我在“城市选择表视图控制器”中添加了一个长条按钮以用作后退按钮,以返回到主界面,并将其链接到出口,但仍无法正常工作。

My CitySelectionTableViewController.m file 我的CitySelectionTableViewController.m文件

#import "CitySelectionTableViewController.h"

@interface CitySelectionTableViewController ()

@end

@implementation CitySelectionTableViewController
- (IBAction)unwindToMainInterfaceViewController:(UIStoryboardSegue *)segue
{
}
...

My storyboard is showing the "Unwind segue from Back to Exit" segue in the document outline, but nothing is happening. 我的情节提要板在文档大纲中显示了“从回退到退出的安全区”安全区,但是没有任何反应。 I can reach the city selection view, but "Back" will not bring me back. 我可以进入城市选择视图,但是“返回”不会带我回来。 Any suggestions? 有什么建议么? I do realize this is a fairly common question, but I've tried many answers from StackOverflow and others with no success. 我确实意识到这是一个相当普遍的问题,但是我尝试了StackOverflow的许多答案,但都没有成功。

You shouldn't have two navigation controllers in your chain. 您不应在链中有两个导航控制器。 You cannot go back from the CitySelectionTableViewController since it is already the first view controller of the navigation controller it's embedded in, and there's nowhere to go back to. 您不能从CitySelectionTableViewController返回,因为它已经是其嵌入的导航控制器的第一个视图控制器,并且无处可退。 You should have just one controller for one navigation stack: 您应该只有一个控制器用于一个导航堆栈:

Nav Controller -> Main Interface Controller -> City Selection Table View Controller 导航控制器->主界面控制器->城市选择表视图控制器

This way everything should work out of the box and you won't even have to manually add the Back button, it will be created automatically when you make the segue from the Main Interface Controller to the City Selection Table View Controller. 这样,所有东西都可以直接使用,甚至不必手动添加“后退”按钮,当您从主界面控制器到“城市选择表视图”控制器进行选择时,它将自动创建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM