UINavigationController “back button” custom text?

后端 未结 16 1484
Happy的楠姐
Happy的楠姐 2020-11-28 01:41

The \"back button\" of a UINavigationController by default shows the title of the last view in the stack. Is there a way to have custom text in the back button

16条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 02:13

    The title of the back button defaults to the previous view's title so a quick trick I use is to place the following code on the previous view's .m file.

    -(void)viewWillAppear:(BOOL)animated {
    
        // Set title
        self.navigationItem.title=@"Original Title";
    }
    
    -(void)viewWillDisappear:(BOOL)animated {
    
        // Set title
        self.navigationItem.title=@"Back";
    }
    

提交回复
热议问题