-1

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

BEFORE presented actionSheet - ImageView (red background w/ blue gradient image) of UITableViewCell

AFTER on presented actionSheet - ImageView (red background w/o blue gradient image)

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)
}
Chris
  • 441
  • 5
  • 24
  • 1
    The issue could be in `AlertController.showActionSheet`. Also, `completion(true)` probably shouldn't be called until an option has been selected from the alert. – Craig Siemens Nov 14 '18 at 18:50
  • @CleverError thanks.i added above my showActionSheet method for reference. any thoughts there, it looks okay to me...i actually have this entire setup replicated elsewhere and i don't receive the same "glitch" although the view hierarchies are different (if that even matters in this case).. – Chris Nov 14 '18 at 19:22

1 Answers1

0

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.

Chris
  • 441
  • 5
  • 24