iOS 返回指定控制器
程序员文章站
2022-06-04 13:17:37
...
开发中会遇到在列表页面查看详情,之后编辑内容,编辑完成之后需要返回到列表页面,大概有两种实现方式:
<pre><code>`
//索引
NSInteger index = [[self.navigationController viewControllers] indexOfObject:self];
if (index>2) {
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:(index-2)] animated:YES];
} else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
//类型判断
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[UIViewController class]]) {
//TODO
break;
}
}`</code></pre>
下一篇: nginx 使用