从没有UINavigationController和后退按钮的推送视图返回,是否可能?

时间:2013-12-29 12:44:31

标签: ios iphone objective-c cocoa-touch uitableview

我有ViewController,例如startingScreenViewController。我从此视图中的项目推送segue到另一个视图(someViewController),其中ViewController当前有TableView(当然不是TableViewController)。现在,如果没有后退按钮,我想通过点击表格视图中的单元格返回第一个视图。我写过我的小组代表:

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

我尝试使用

[self.navigationController popViewControllerAnimated:YES];

显然它不起作用,因为我没有navigationController。我甚至试图回到startingScreenViewController,这是一件愚蠢的事,也没有用。

我需要一些帮助,我们非常感谢你的建议。

2 个答案:

答案 0 :(得分:0)

我不知道如何在没有someViewController的情况下使用push segue打开UINavigationController,但如果有效,请尝试使用此代码:

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

当然,检查一下,是view controller的{​​{1}} delegate

答案 1 :(得分:0)

简短的回答是,当您没有导航控制器时,不要使用push segue。这应该根本不起作用,它确实起作用的事实是一个意外。无法保证它将来会继续发挥作用。

使用模态presentViewController:animated:完成调用,使用相应的调用将其关闭。

相关问题