执行push segue后,“后退”按钮不会出现

时间:2014-12-17 10:45:56

标签: ios objective-c iphone

我',执行一个基本的推送segue(使用nib)和从一个视图控制器到另一个表视图控制器,并且由于某种原因,“Back”按钮没有出现,通常它确实出现。

这就是我执行推送的方式:

@interface HomeViewController ()

@end

@implementation HomeViewController

- (id)init {
    self = [super initWithNibName:@"HomeViewController" bundle:nil];
    if (self) {
        // Do something
    }
    return self;
}

- (void)viewDidLoad {

    [super viewDidLoad];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (IBAction)goToStack:(id)sender {

    StackTableViewController *stackViewController = [[StackTableViewController alloc] initWithNibName:@"StackTableViewController" bundle:nil];
    [self.navigationController pushViewController:stackViewController animated:YES];
}

2 个答案:

答案 0 :(得分:6)

StackTableViewController中,您应将setNavigationBarHidden设为NO

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

答案 1 :(得分:0)

要确保每次从视图控制器(HomeViewController)导航时导航栏再次出现,请使用以下命令:

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}