gpt4 book ai didi

objective-c - 后退按钮文字没有改变

转载 作者:搜寻专家 更新时间:2023-10-30 20:01:00 26 4
gpt4 key购买 nike

对于我的 View Controller 之一(扩展 UITableViewController),我需要将其后退按钮文本配置为“后退”。但是后退按钮仍然显示父 View Controller 的标题(默认)。

- (void)viewDidLoad
{
...
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];
}

最佳答案

您需要在将类插入堆栈的 View Controller 上设置后退按钮,例如创建并推送您正在显示的类的 Controller

View Controller Programming Guide for iOS 的文档建议将 UINavigationItem 保存在 Navigation Item Stack 中,它为堆栈中的当前项目提供标题和按钮。

重要的(我在[]中加了位)

Although most of the navigation bar’s content is obtained from the topmost navigation item [in the navigation stack], a pointer to the back item [of the previous item in the stack] is maintained so that a back button (with the title of the preceding item) can be created.

查看 Configuring the Navigation Item Object 部分下的文档,有一个图表显示堆栈和指向顶部项目下方项目的 backItem堆。在您的情况下,堆栈中的顶部项目将引用您正在显示的类的 UINavigationItem,而 backItem 将是指向推送它的类的指针。

注意
看看文档中的那个部分,一张图片值一千字

关于objective-c - 后退按钮文字没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8250904/

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