I have an iOS 7 app where I am setting a custom back button like this:
UIImage *backButtonImage = [UIImage imageNamed:@"back-button"];
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setImage:backButtonImage forState:UIControlStateNormal];
backButton.frame = CGRectMake(0, 0, 20, 20);
UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
viewController.navigationItem.leftBarButtonItem = backBarButtonItem;
IMPORTANT: This is a hack. I would recommend taking a look at this answer.
Calling the following line after assigning the
leftBarButtonItem worked for me:
self.navigationController.interactivePopGestureRecognizer.delegate = self;
This does not work if called in
init methods. It should be called in
viewDidLoad or similar methods.