gpt4 book ai didi

ios - 如何更改 UINavigationController 后退按钮名称?

转载 作者:IT王子 更新时间:2023-10-29 07:34:35 26 4
gpt4 key购买 nike

我有一个 UIViewController,我正在从我的第一个 View Controller 导航到第二个 View Controller ,我想更改 navigationcontroller 上显示的按钮的名称回去....

SecondViewController *secondController = [[SecondViewController alloc]
initWithNibName:nil
bundle:NULL];
[self.navigationController pushViewController:secondController animated:YES];

现在在第二个 viewcontroller 中,我想更改 navigationController 中按钮的名称。

最佳答案

如果您希望以编程方式执行此操作,可以这样做:

objective-C

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

[self.navigationItem setBackBarButtonItem:backItem];

swift

let backItem = UIBarButtonItem(title: "Custom", style: .Bordered, target: nil, action: nil)
navigationItem.backBarButtonItem = backItem

但是,如果您更喜欢使用 Interface Builder,只需选择您希望为其设置后退按钮的 UINavigationItem,然后导航到属性检查器以更改后退按钮的标题。

enter image description here

注意:重要的是要记住,您必须在点击后退按钮后返回的 View Controller 上进行配置,而不是当前可见的 View Controller 。

关于ios - 如何更改 UINavigationController 后退按钮名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9871578/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com