How to remove all navigationbar back button title

后端 未结 30 3422
后悔当初
后悔当初 2020-12-12 15:42

When I push a UIViewController, it has some title in back button at new UIViewController, if the title has a lot of text, It does not look good in

30条回答
  •  眼角桃花
    2020-12-12 15:57

    Simple Solution :

    While you are pushing 2nd controller from 1st controller, put self.navigationItem.title = "" in viewWillDisappear of 1st controller. It hides back button title from 2nd controller.

    Above statment hides 1st controllers title, hence when we came back we want title for 1st controller again. For that we have add title for 1st controller in viewWillAppear method of 1st controller.

    Refer following methods (of 1st controller)

        override func viewWillDisappear(_ animated: Bool) {
        self.navigationItem.title = ""
    }
    
    override func viewWillAppear(_ animated: Bool) {
        self.navigationItem.title = "Title"
    }
    

提交回复
热议问题