如何在没有pop的情况下返回上一个视图

时间:2014-10-16 23:29:51

标签: ios objective-c

在didSelectRowAtIndexPath上我想返回上一个viewcontroller。我现在正在使用此代码:

[self.navigationController popViewControllerAnimated:YES];

但是,我不想从navigationcontroller弹出。因为,当用户“点击”后退按钮时,我想返回此视图。

所以,我想回到以前的控制器,而不是从navigationcontroller中弹出它。有可能吗?

谢谢!

2 个答案:

答案 0 :(得分:0)

尝试使用[self presentViewController:vc animated:YES completion:nil];代替

答案 1 :(得分:0)

似乎您想要推送上一个视图控制器,您可以使用UINavigtionController viewControllers属性。
所以你的代码可能会喜欢这个 [self presentViewController:[self.navigationController.viewControllers objectAtIndex:[self.navigationController.viewControllers.count-2]] animated:YES completion:nil];