Search code examples
iosobjective-cuinavigationcontrolleruitoolbar

Pop view controller off stack without a navigation bar shown?


I've hidden the navigation bar so I can have a custom UIToolBar up there, but when I set the action property for the toolbar item to a method that pops it, it won't work, and I think it may be because I hid the navigation bar.

Here's my code:

[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Articles" style:UIBarButtonItemStyleBordered target:nil action:@selector(backButtonTapped)]];

...

- (void)backButtonTapped {
    [self.navigationController popViewControllerAnimated:YES];
}

But nothing happens.


Solution

  • I had a UITapGestureRecognizer on the whole view that intercepted the tap on the UIBarButton. I solved it thanks to this answer, which basically stopped the UITapGestureRecognizer from beginning unless it was outside of the UIToolBar.