SwipeLeft Gesture does not work on UITableView

综合技术 2018-02-22 阅读原文

I have a UITableView
. I don't have " canEditRowAtIndexPath
" implemented.

Following code works on controllers which don't have UITableView but does not work on controller with UITableView.

I did try setCancelsTouchesInView = NO
on gestureRecognizer.

In container view controller, I have implemented:

UISwipeGestureRecognizer *leftGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeHandlerLeft:)];
[leftGestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self.view addGestureRecognizer:leftGestureRecognizer];

You better try adding UISwipeGestureRecognizer
to your UITableViewCell
rather than UITableView
Try adding this in your cellForRowAtIndexPath
method:

let recognizer = UISwipeGestureRecognizer(target: collectionView, action: #selector(handleGesture))
        recognizer.direction = .left
        recognizer.numberOfTouchesRequired = 1
        cell .addGestureRecognizer(recognizer)

func handleGesture(){

    }
Hello, buddy!

责编内容by:Hello, buddy!阅读原文】。感谢您的支持!

您可能感兴趣的

UITableView Infinite Scrolling Tutorial Note : This tutorial works with both Xcode 9 and Xcode 10, iOS 11 and iOS 12...
iOS优化(三)没错我还是滑动优化 近期把滑动优化的一些经验整理了一下,在公司做了一次技术分享,和我之前的文章有一小部分重叠。现摘要如下,希望大家不吝赐教,共同讨论进步。 一.滑动优化的玄学...
iOS开发之UIRefreshControl使用踩坑 问题描述 接上一个话题,实现了TabBar的点击刷新以后,开始继续写完成功能,刷新UITableView,于是考虑到 iOS 10 以后, UIScrol...
The complete animation notification after UITableV... UITableView has that built-in animation in which after a cell is reordered, it ...
商品倒计时 for Swift 因公司项目添加商品倒计时需求,故针对商品倒计时模块做了个Demo,也是对自己的总结; 经过370041534群里的朋友提醒,既然是cell上有多个倒计...