UITableViewCell 内容消失

UITableViewCell Content Disappears

我有一个 uiTableView,其中包含 3 个单元格,这些单元格具有通过 trailingSwipeActionsConfigurationForRowAt 委托方法实现的 uiContextualAction

点击 uiContextualAction 我显示一个 actionSheet 有两个操作 - 删除和关闭。

actionSheet 在没有按下任何操作的情况下显示时,所有 3 个单元格的单元格内容,特别是 uiImageView 突然消失。

uiTableViews 是否有某些内在因素导致了这种情况?我在上述流程中放置了断点,但对如何补救无济于事。如有任何想法,我们将不胜感激。

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)
}

仍然不确定问题是什么is/was...但是我将矢量图像替换为 png,它似乎在渲染并且不再突然消失了..

不是确定的解决方案,但它现在正好适合我。