如何删除后退按钮的文本。

当前返回按钮:

<返回

需要的后退按钮:

< 其他任何东西

这些都没有奏效:

self.navigationItem.backBarButtonItem?.title = "Back"
self.backItem?.title = ""
self.navigationController?.navigationBar.backItem?.title = ""
self.navigationItem.backBarButtonItem?.title = ""
self.navigationController?.navigationItem.backBarButtonItem?.title="Back"
self.navigationController?.navigationBar.backItem?.title = ""
self.navigationController?.navigationItem.backBarButtonItem?.title

当前回答

如果你对任何多星建议有问题,确保你在viewDidLoad()中注册你的UITableViewCells,而不是从init()

其他回答

我不知道你在哪里使用了你的方法,你把你的问题,但我可以得到想要的结果,如果我使用,在我的ViewController类(其中我想改变后退按钮),在viewDidLoad()函数,以下一行:

self.navigationController?.navigationBar.backItem?.title = "Anything Else"

结果将是:

之前

override func viewWillAppear(_ animated: Bool) {

    self.tabBarController?.navigationItem.title = "Notes"

    let sendButton = UIBarButtonItem(title: "New", style: .plain, target: self, action: #selector(goToNoteEditorViewController))

    self.tabBarController?.navigationItem.rightBarButtonItem = sendButton
}

func goToNoteEditorViewController(){
   // action what you want
}

希望能有所帮助!!3 #迅速

有两种不同的方法来植入那部分,  

1.

navigationItem.backButtonTitle = "Title Goes Here"

(5)迅速

  2.

 let backButton = UIBarButtonItem()

backButton。title = "标题在这里" self.navigationController .navigationBar.topItem ?。backBarButtonItem = backButton

 

虽然这些答案解决了问题,但这可能是一些有用的

class MainNavigatioController: UINavigationController {

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        // first
        let backItem = UIBarButtonItem()
        backItem.title = "رجوع"
        self.viewControllers.last?.navigationItem.backBarButtonItem = backItem
        // then
        super.pushViewController(viewController, animated: animated)

    }

}

自我。标题= "" 之前self.navigationController ?。pushViewController(vc, animated: true)。