OGeek|极客世界-中国程序员成长平台

标题: ios - 将导航栏后退按钮标题重置为默认 iOS [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 17:45
标题: ios - 将导航栏后退按钮标题重置为默认 iOS

我知道我可以设置导航栏后退按钮的标题:

self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)

但是,我的应用程序的某些部分我想将其设置回默认文本“返回”(也将使用本地化)。我该怎么做呢?



Best Answer-推荐答案


当我在父 View Controller 中调用 pushViewController 之后立即放置它时,这个小技巧似乎起作用了。

然而,我在 iPad Pro 模拟器上的测试表明,它不仅试图显示缩写文本,而且后退按钮甚至会覆盖任何打算出现在右侧的 UIButtonBarItem

let backButtonItem = UIBarButtonItem()
backButtonItem.title = "A button title which is much too long to be displayed in the navigation bar, so that iOS will replace this text with localized 'Back' button text."
navigationItem.backBarButtonItem = backButtonItem

关于ios - 将导航栏后退按钮标题重置为默认 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39887978/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4