如何让 UINavigation 控制器导航到前一个视图而不是前一个视图.基本上我希望它跳回 2 个位置而不是默认位置.
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];
感谢您的帮助.
设置:
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style: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];
}
这篇关于如何让导航栏后退按钮返回到另一个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!