UITableview仅允许在一个方向上滑动删除 [英] UITableview only allow swipe to delete in one direction

查看:37
本文介绍了UITableview仅允许在一个方向上滑动删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启用了编辑"模式的表格视图,因此用户可以在单元格的任何方向上滑动以显示删除"按钮.但是,我在整个表视图中都有一个手势,可以向右滑动以执行其他与删除无关的操作.如果要删除的滑动仅在左滑动上起作用,那么我想这样做,以便在右滑动上调用我的手势识别器.现在,tableview滑动会完全覆盖我的手势识别器.

I have a tableview in which Edit mode is enabled, so the user can swipe in any direction on a cell to bring up the delete button. However, I have a gesture on the whole tableview for right swipes to do something else, unrelated to the deletion. I would like it if the swipe to delete only worked on a left swipe, so that my gesture recognizer would be called on the right swipe. Right now, the tableview swipe completely overrides my gesture recognizer.

有什么办法可以解决这个问题?

Is there any way to fix this?

谢谢

推荐答案

您只需要向tableView添加一个SwipeGesture,重要的是不要设置swipeGesture的委托并且不实现gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer 功能.

You just need to add a SwipeGesture to tableView and important thing is do not set the delegate of swipeGesture and do not implement gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer function.

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(callYourMehod:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.table addGestureRecognizer:swipeRight];

它应该按照我在代码中实现和使用的方式工作这样一来,表格单元格就不会在向右滑动时进入编辑模式.

It should work as I have implemented and used it in my code This is how table cells will not go in edit mode on right swipe.

这篇关于UITableview仅允许在一个方向上滑动删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆