Petar
Petar

Reputation: 2283

iOS: Disable UITableView selection after tap and hold a cell

I have a UITableView with custom UITableViewCells displayed inside a modal view controller. When the cell is selected, I am pushing a new UIViewController onto the navigation stack. All standard but I have found a strange bug with this:

Say I have 10 cells displayed in the table view. If I tap and hold on one cell and use another finger to randomly tap on other cells, after I release my fingers, there are multiple UIViewControllers pushed on top of each other. I guess it makes sense, as I am calling didSelectRowAtIndexPath multiple times. However, I have no idea how to fix it ?

I am getting the error: "nested push animation can result in corrupted navigation bar" and : "Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted."

I am setting exclusivieTouch to YES on the cells as well as delaysContentTouches to NO on the tableView.

Upvotes: 1

Views: 1303

Answers (1)

sunkehappy
sunkehappy

Reputation: 9091

Try to disable multiple selection of the table view(by setting tableView.allowsMultipleSelection = NO;, this is by default. So maybe you just need to remove your setting it to YES code). It doesn't make sense to allow user's multiple selection if it's to present a view controller. Because only one can be presented.

Upvotes: 1

Related Questions