如何获取uinavigation栏后退按钮返回到Anthother视图控制器 [英] How to get a uinavigation bar back button to return to anthother view controller
本文介绍了如何获取uinavigation栏后退按钮返回到Anthother视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让UINavigation控制器导航到之前的视图,而不是之前的视图。基本上我希望它跳回2个位置而不是默认值。
这是非常规的我确定,但我现在只需要这样做。
self.navigationItem.backBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@Back
style:UIBarButtonItemStyleBordered
target:nil
action:nil] autorelease];
感谢您的帮助。
设置:
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@ Back样式:UIBarButtonItemStyleBordered target:self action:@selector(goBack)] autorelease];
然后创建方法 -goBack
- (void)goBack
{
UIViewController * ctrl = [self.navigationController.viewControllers objectAtIndex:self。 navigationController.viewControllers.count - 2];
[self.navigationController popToViewController:ctrl animated:YES];
}
How would I go about having a UINavigation controller navigate not to the previous view but the view before that. Basically I would like it to jump back 2 places instead of the default one.
This is unconventional I'm sure, but I just need to do it for now.
self.navigationItem.backBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:nil
action:nil] autorelease];
thanks for any help.
解决方案
Set:
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(goBack)] autorelease];
then create a method -goBack
-(void)goBack
{
UIViewController *ctrl = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count - 2];
[self.navigationController popToViewController:ctrl animated:YES];
}
这篇关于如何获取uinavigation栏后退按钮返回到Anthother视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文