简体   繁体   English

从没有UINavigationController和后退按钮的推送视图返回,可以吗?

[英]Coming back from a push view without a UINavigationController and a back button, is it possible?

I have a ViewController , for example startingScreenViewController . 我有一个ViewController ,例如startingScreenViewController I have a push segue from an item on this view to another view ( someViewController ) which is a ViewController that has a TableView (not TableViewController of course) in it. 我有一个从该视图上的项目到另一个视图( someViewController )的推送服务,该视图是其中具有TableView (当然不是TableViewController )的ViewController Now, without having a back button I want to go back to the first view by tapping on a cell in table view. 现在,我没有后退按钮,而是想通过单击表视图中的单元格返回到第一个视图。 I have written my cell delegate: 我已经写了我的细胞代表:

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}

I tried using 我尝试使用

[self.navigationController popViewControllerAnimated:YES];

and obviously it didn't work, since I don't have a navigationController . 显然它没有用,因为我没有navigationController I even tried to segue back to the startingScreenViewController which was a stupid thing to do and also didn't work. 我甚至想Segue公司回startingScreenViewController这是做愚蠢的事,也没有工作。

I'm in need of some help, and suggestions would be much appreciated. 我需要一些帮助,建议将不胜感激。

I don't know how you manage to open someViewController with push segue without UINavigationController , but if it works, try to use this code: 我不知道如何在不使用UINavigationController情况下通过push segue打开someViewController ,但是如果someViewController ,请尝试使用以下代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   [self dismissViewControllerAnimated:YES completion:nil];
}

And, of course, check, is your view controller delegate of table view . 而且,当然,检查是您的table view view controller delegate

The short answer is to not use a push segue when you don't have a navigation controller. 简短的答案是,当您没有导航控制器时,不要使用推送功能。 That should not work at all, and the fact that it does work is an accident. 那根本不起作用,而且它确实起作用是一个意外。 There is no guarantee that it will continue to work in the future. 无法保证它将在将来继续工作。

Use a modal presentViewController:animated:completion call, the dismiss it using the corresponding call. 使用模态的presentViewController:animated:completion调用,使用相应的调用将其关闭。

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

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