我有一个UINavigationController在堆栈上包含3个UIViewControllers。

View A - is the root
View B - is pushed by View A and has `self.navigationItem.hidesBackButton = YES;`
View C - is pushed by View B and has `self.navigationItem.hidesBackButton = NO;`

即使我将hidesBackButton设置为NO, View C也不显示后退按钮。我该如何解决?

最佳答案

更新
4.2可能存在的错误,直到4.1 sdks为止

我已经尝试过了,我的工作正常。我只是发布B View Controller (BVC)和C View Controller (CVC)的实现。我最初的猜测是您没有在viewDidLoad中设置BVC的标题。

@implementation BVC


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"I am B";
}


- (void) viewWillAppear:(BOOL)animated{
    self.navigationItem.hidesBackButton = YES;
}

- (IBAction)pushB:(UIButton *)sender{
    CVC *cvc = [[CVC alloc] initWithNibName:@"CVC" bundle:nil];
    [self.navigationController pushViewController:cvc animated:YES];
    [cvc release];
}
@end

@implementation CVC

- (void) viewWillAppear:(BOOL)animated{
    self.navigationItem.hidesBackButton = NO;
}
@end

10-08 11:03