首页 > 解决方案 > UITableView 滑动自定义按钮消失

问题描述

UITableViewCell触发滑动操作时,我的自定义有问题。我的单元格中有 a UIStepperUILabels 和 a UIImage,但是当我滑动时,只有UIStepper元素消失了。完成/取消滑动动作时,会UIStepper在短时间内重新出现。请看附件gif:

在此处输入图像描述

这是实现滑动动作的代码:

override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
    let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, view, handler) in
        print("Delete Action Tapped")
    }

    let editAction = UIContextualAction(style: .destructive, title: "Edit") { (action, view, handler) in
        print("Add Action Tapped")
    }

    editAction.backgroundColor = .orange
    deleteAction.backgroundColor = .red
    let configuration = UISwipeActionsConfiguration(actions: [deleteAction, editAction])
    return configuration
}

使用适用于 iOS 12 的 Swift 4.2 和 Xcode 10。任何帮助将不胜感激!

标签: iosswiftuitableview

解决方案


推荐阅读