我有一个包含4个UIButtons的表格单元格视图:
按钮有Touch Up Inside事件
@IBAction func increasDealRatingAction(sender:UIButton) {
let buttonPosition = sender.convertPoint(CGPointZero, toView: self.tableView)
if let indexPath = self.tableView.indexPathForRowAtPoint(buttonPosition) {
...
}
}
我对每个单元格都有编辑操作:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
...
return [addToWishListAction, addToPurchasesAction, deleteAction]
}
问题是,当您向左滑动以显示“添加到愿望清单”,“删除”星形按钮位置的操作,点击处理过的事件或滑动按钮区域时无法检测到滑动操作。< / p>
答案 0 :(得分:0)
向按钮添加滑动手势识别器
// Not clear how to store offset unless custom SplitFunc provided
inputFile.Seek(GetCounter(), 0)
scanner := bufio.NewScanner(inputFile)
并实施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:)
。