The answer to this question is not simple, because UITableView manages a lot of touches, and this touches are managed by different components.
So, to give you a correct and working answer, you have to explain:
- what kind of swipes you want to disable (left-to-right, right-to-left)
- where (on the empty table view, on the cell)
- what happens now when you do this swipe (the cell goes in edit mode, a navigation controller goes to the previous page ecc....)
For example: the swipe-to-delete on a UITableViewCell can't be avoided by overriding touchesBegan:withEvent
, because the touch is received by the internal content view (UITableViewCellContentView
private class, so you can't subclass and override touchesBegan:withEvent
).
But this is not necessary, because you can disable this behavior adding this method to UITableViewController:
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleNone;
}
When you disable the editing (for example) the cell and the table view are no more capable of managing the touch, so the touch is forwarded to the next responder in the chain.
This is only one example, you must explain all the cases that are giving you undesider behavior to let us help you more.
Last suggestions:
At this Page you will find a very good and interesting explanation on how the hit test end event handling process works.
I'll update the answer with more specific information when you'll add more details.
Regards
Fabio