无法在UINavigationController上设置后退按钮

时间:2019-02-27 07:04:54

标签: ios uiviewcontroller uinavigationbar uibarbuttonitem uinavigationitem

我正在向我的视图控制器显示以下代码:

UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:sessionController];
[self presentViewController:navigation animated:YES completion:^{
}];

在呈现的视图控制器的“ viewDidLoad”方法中,我尝试如下设置“后退按钮”:

UIBarButtonItem *newBackButton =
[[UIBarButtonItem alloc] initWithTitle:@"Test"
                                 style:UIBarButtonItemStyleBordered
                                target:nil
                                action:nil];
[self.navigationController.navigationItem setBackBarButtonItem:newBackButton];

静默故障,无异常,无日志,无错误和NO按钮。任何想法将不胜感激!

1 个答案:

答案 0 :(得分:0)

您可以尝试:

self.navigationItem.leftBarButtonItem = newBackButton