ios - UIButton 和 UITextField 将阻止 UITableViewCell 被滑动删除

标签 ios uitableview delete-row

UITableViewCell中有UIButtonUITextField。删除按钮enter image description here当我滑过 UIButtonUITextField 时不会出现。我确实在SO和google上搜索答案,有一个类似的问题Swipe left gestures over UITextField , 但没有正确答案。

我在 iOS 8 上遇到了这个问题。

编辑 设置 self.tableView.panGestureRecognizer.delaysTouchesBegan = YES; 后,它非常适合带有 UITextField 的单元格。但是当我从 UIButton 开始拖动时,显示删除按钮并触发 UIButton,我不希望 UIButton 被触发。

最佳答案

我不知道如何首先阻止 UIButton 触发,但是 UITableViewCell 具有属性 showingDeleteConfirmation 可以用于检查是否显示删除按钮。我所做的是在 TouchUpInsideUIButton 操作中检查它,就像这样

- (void)buttonPressed:(id)sender
{
    if (!self.showingDeleteConfirmation) {
        // Handle button press
    }
}

(此示例来自 UITableViewCell 子类,因此它使用 self 来访问该属性。)

这个,除了

tableView.panGestureRecognizer.delaysTouchesBegan = YES;

你已经拥有的,可以正确识别滑动并且不执行按钮操作。

关于ios - UIButton 和 UITextField 将阻止 UITableViewCell 被滑动删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26436643/

相关文章:

ios - iPad2 中的相册崩溃

objective-c - -[UITableView _endCellAnimationsWithContext :] 中的断言失败

PHP 删除按钮...不起作用(模态)

mysql - 删除MySQL中包含[A-Za-z0-9]以外的所有字符的行

ios - CoreData 未触发故障

iphone - 如何从委托(delegate)外部设置 super View ?

ios - 如何在与单元格宽度相同的 UITableViewCell 中插入 UIProgressView?

ios - heightForHeaderInSection 中的未捕获异常

postgresql - 如何获取 PostgreSQL 中删除的行数?

ios - 如何实现神经艺术作品来获取ios的艺术绘画图像?