nburk nburk - 1 month ago 7
iOS Question

Prevent UITableView from receiving two touches (nested pop animation can result in corrupted navigation bar)

I am using a

UITableView
in my app, which when tapped will use
UINavigationController
to push another view controller onto the navigation controller's view controller stack.

However, when a cell on the tableview is double †apped,
tableView:didSelectRowAtIndexPath:
gets called twice, causing the navigation controller to push two of these new viewcontroller s on the stack and resulting in the following console output:

nested pop animation can result in corrupted navigation bar
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.


It's not a very important issue, because users are not very likely to perform a double tap on the table view cells, however I was wondering if there is an elegant solution to prevent this kind of misnavigation? (maybe checking the navigation controller's
topViewController
and subsequently decide whether the push
pushViewController:
method should actually be performed?).

Answer

Here is one line solution

self.tableView.multipleTouchEnabled = NO;
Comments