我有一个通过委托方法实现的uiTableView
3 个单元格。uiContextualAction
trailingSwipeActionsConfigurationForRowAt
点击uiContextualAction
我会显示actionSheet
两个操作 - 删除和关闭。
当在actionSheet
没有按下任何操作的情况下显示 时,所有 3 个单元格的单元格内容,特别是 auiImageView
突然消失。
uiTableViews
造成这种情况有什么固有的吗?我在上述流程中放置了断点,但对如何解决这个问题无济于事。任何想法将不胜感激。
在呈现 actionSheet 之前 - UITableViewCell 的 ImageView(红色背景和蓝色渐变图像)
在呈现的 actionSheet 之后 - ImageView(红色背景没有蓝色渐变图像)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let delete = UIContextualAction(style: .normal, title: "") { (action, view, completion) in
self.onDeleteCell(indexPath)
completion(true)
}
delete.backgroundColor = UIColor.red
delete.image = #imageLiteral(resourceName: "x_circle")
let config = UISwipeActionsConfiguration(actions: [delete])
config.performsFirstActionWithFullSwipe = false
return config
}
func onDelete(_ indexPath: IndexPath) {
AlertController.showActionSheet(self, title: nil, message: nil, actionOneTitle: "Delete", actionOneStyle: .destructive, actionTwoTitle: "Dismiss", actionTwoStyle: .cancel) { (_) in
self.updateCells(indexPath)
}
}
//From custom AlertController class
static func showActionSheet(_ inViewController: UIViewController, title: String?, message: String?, actionOneTitle: String, actionOneStyle: UIAlertAction.Style, actionTwoTitle: String, actionTwoStyle: UIAlertAction.Style, actionOneHandler: @escaping ((UIAlertAction) -> Void)) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
let actionOne = UIAlertAction(title: actionOneTitle, style: actionOneStyle, handler: actionOneHandler)
alert.addAction(actionOne)
let actionTwo = UIAlertAction(title: actionTwoTitle, style: actionTwoStyle, handler: nil)
alert.addAction(actionTwo)
inViewController.present(alert, animated: true, completion: nil)
}