单元格滑动事件和按钮触摸事件内部 [英] Cell swipe event and button touch inside event

查看:30
本文介绍了单元格滑动事件和按钮触摸事件内部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 4 个 UIButton 的表格单元格视图:

I have a table cell view with 4 UIButtons:

按钮有 Touch Up Inside 事件

Buttons have Touch Up Inside event

@IBAction func increasDealRatingAction(sender:UIButton) {
    let buttonPosition = sender.convertPoint(CGPointZero, toView: self.tableView)
    if let indexPath = self.tableView.indexPathForRowAtPoint(buttonPosition) {
       ...
    }
}

我对每个单元格都有编辑操作:

And i have edit actions for each cell:

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
    ...
    return [addToWishListAction, addToPurchasesAction, deleteAction]
}

问题,当您向左滑动以显示添加到愿望清单"、删除"星形按钮位置的操作时,也处理了单击事件或在您滑动按钮区域时未检测到滑动操作.

The issue, when you swipe left to show "add to wish list", "delete" actions from position of star buttons, click event handled too or swipe action doesn't detect while you swipe on button area.

推荐答案

向按钮添加滑动手势识别器

Add a swipe gesture recognizer to the buttons

let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:")) // nil for selector is also possible
swipeGestureRecognizer.direction = .Left // Add this if you want only one direction
dealRatingButton.addGestureRecognizer(swipeGestureRecognizer)
// Add three star buttons

并实现 gestureRecognizer(_:shouldReceiveTouch:) 返回 false.

这篇关于单元格滑动事件和按钮触摸事件内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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