How to create backBarButtomItem with custom view for a UINavigationController

前端 未结 14 1210
余生分开走
余生分开走 2020-11-29 19:39

I have a UINavigationController into which I push several views. Inside viewDidLoad for one of these views I want to set the self.navigationI

14条回答
  •  青春惊慌失措
    2020-11-29 20:10

    I think I found the solution for this. Simply set the button on the navigation item on the previous controller (The one that you want to go back to)

    So if I have for example a root controller and I push a second controller and want to customize the back button then I should do the following:

    self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc]
        initWithImage:[UIImage imageNamed:@"ico.png"] style:UIBarButtonItemStyleBordered
        target:nil action:nil] autorelease];
    

    Where self is the root view controller and not the second one.

提交回复
热议问题