Change < Back button text of iOS or iPadOS App.

While we use app development methodologies like MVC (Model, View, Controller), we encounter problems navigating from one view to another. How do you change the text of the back button, which gets populated automatically by the Apple iOS operating system?

You can use the below method in the viewDidLoad method of your root view:

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

Here is another way of doing the same, which can be done in the ‘prepare for segue’ method of your app:

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if segue.identifier == "showImage" {

let backItem = UIBarButtonItem()
backItem.title = "Back";
navigationItem.backBarButtonItem = backItem
}
}

I hope this helps,

Thanks & Regards
Mandar Apte

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply