我想知道是否可以使用导航控制器按钮返回到上一页。现在,我已经使用此代码定制了按钮
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:mainLib.navCountryTitle
style:UIBarButtonItemStyleBordered
target:self
action:@selector(handleBack:)];
在“handleback”方法中,我调用了这一行
[self.navigationController popViewControllerAnimated:YES];
所以在这种情况下,它将转到上一个屏幕。但是我想转到上一个屏幕之前的屏幕。
我知道我可以立即调用该屏幕,但我不想这样做,因为在每个屏幕中我都有一个后退按钮,该按钮应该转到其上一个屏幕。
您可以使用其推送索引弹出到特定的视图控制器。如果你知道语法那么你可以这样做
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:indexOfViewController] animated:YES];
我相信,在你的情况下,这将是第一个索引。尽管您可以再次更改索引并检查。
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
这里 self.navigationController.viewControllers 是推送的所有 ViewController 的数组。
希望能帮助到你。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)