IOS连续退出多个界面(回退到指定界面)

时间:2020-09-17 19:37:23   收藏:0   阅读:43

在一个navigationController中,我们可以借助nc去拿出所有界面的列表,放到数组中,然后根据下表使用popToViewController方法回退到指定界面:

// 取navigationCtroller中的Controllers  
NSArray * navArray = self.navigationController.viewControllers;  
// 取出后在根据索引进行跳转到指定位置  
[self.navigationController popToViewController:[navArray objectAtIndex:0] animated:YES]; 

  有时候我们提供给我别人的SDK中,我们从当前界面往回退,就要从后面往前数啦。我们的当前界面是顶层,下表就是count-1.所以如果连续回跳两个界面的话下标就是count-3了。

也就是:

[self.navigationController popToViewController:[navArray objectAtIndex:0] animated:YES]; 

  

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!