Adam
Adam

Reputation: 9049

Adding a custom back button to NavigationBarController created in nib

- (void)viewDidLoad {


    UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"goback.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(//HERE ! i don't know put what thing !) forControlEvents:UIControlEventTouchUpInside];
    [button setFrame:CGRectMake(0, 0, 32, 32)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];


}

I found this example, however I don't know where to put it. My navbar was created in the nib. I could add this code to every view in my navbar, but I only want to write it once.

Thanks

Upvotes: 1

Views: 593

Answers (1)

Nathanial Woolls
Nathanial Woolls

Reputation: 5291

The code you posted would need to either be in each view controller (not view, they are different), or you could create a single view controller class with this code, and descend your other view controllers from it.

Upvotes: 1

Related Questions