I have a uiTableView
with 3 cells that have a uiContextualAction
implemented through the trailingSwipeActionsConfigurationForRowAt
delegate method.
On tap of the uiContextualAction
I display an actionSheet
with two actions - delete and dismiss.
When the actionSheet
is displayed without having pressed any action, the cell's content for all 3 cells, specifically a uiImageView
suddenly disappears.
Is there something inherent to uiTableViews
causing this? I placed breakpoints throughout the aforementioned flow but to no avail on how to remedy this. Any thoughts would be appreciated.
BEFORE presented actionSheet - ImageView (red background w/ blue gradient image) of UITableViewCell
AFTER on presented actionSheet - ImageView (red background w/o blue gradient image)
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)
}
Still unsure what the issue is/was...but I replaced the vector image as png and it appears to render and not suddenly vanish anymore..
Not a definitive solution, but it for now happens to work for me.