从 pushViewController 视图设置后退按钮

set the back button from the pushViewController view

我有一个viewControllerA,可不可以我预先设置viewControllerB的后退键,按下去的时候

Controller *B = [Controller viewControllerFromStoryboardWithProfile: profile editMode: NO];

    UIBarButtonItem *newBackButton =
    [[UIBarButtonItem alloc] initWithTitle:@"Home"
                                     style:UIBarButtonItemStyleBordered
                                    target:nil
                                    action:nil];

    [B.navigationItem setBackBarButtonItem:newBackButton];

    [self.navigationController pushViewController:B animated:YES];

是这样的吗?

试试这个代码:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Home"
                                 style:UIBarButtonItemStyleBordered
                                target:nil
                                action:nil];

self.navigationItem.backBarButtonItem = backButton;
[backButton release];

[self.navigationController pushViewController:anotherViewController];

来源:How to create backBarButtomItem with custom view for a UINavigationController