0

I try to change the title of the back button of the DetailView which was automatically generated by the MasterViewApp. Tried to change it with the following code:


 override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Zurück", style: .plain, target: self, action: #selector(backButtonPressed(_:)))
    }

@objc
       func backButtonPressed(_ sender: UIBarButtonItem) {
        self.dismiss(animated: true, completion: nil)
       }

The button changed as wished to "Zurück", but the the Master View will not appear. Is there another way to make the title adaption work? Or is there a problem with self.dismiss?

Angie
  • 41
  • 1
  • 7
  • You should not dismiss. Dismiss will remove the entire navigationController from the stack. What you want is to go back. If you wanna change the back button title just give the master view controller the title of “Zurück” – Galo Torres Sevilla Dec 14 '19 at 17:37
  • Perfect I have just named the bar item button at detail view "zurück". it works now perfectly. Thank you – Angie Dec 14 '19 at 21:16

0 Answers0