Navigationbar title and back button name are same?

前端 未结 5 923
傲寒
傲寒 2020-12-17 03:50

I created one title for navigationbar in my storyboard project ,but when I moved to next viewcontroller the back button shows the same name as my previous navigationbar(Main

5条回答
  •  情深已故
    2020-12-17 04:24

    According to UINavigationItem Class Reference

    "When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item. [...] If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead."

    So try this in your first VC from where you are pushing other VC

    self.navigationItem.title=@"Recent Books";
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
                                       initWithTitle:@"Back"
                                       style:UIBarButtonItemStylePlain
                                       target:nil
                                       action:nil];
    self.navigationItem.backBarButtonItem=backButton;
    

提交回复
热议问题