UITableViewRowAction in simple terms

Hey Devs,


I'm working a simple IOS app driven entirely with a Table View and I'm still very new to Xcode and Swift. I'm currently attempting to add swipe gestures to a Table Cell but am unable to understand the UITableViewRowAction object (again I'm very new to this). I've done research but I can't make heads or tails what it says. Where do I put this, how do I control what actions appear, what are the default actions? Any help is much appreciated.

Answered by QuinceyMorris in 224952022

You need to provide an array of UITableViewRowAction objects, one per action you want the table rows to offer. (AFAIK you don't have to implement the swiping part yourself.) This is not additive, so when you provide this array it replaces the default behavior, and you must contain all the possible actions you want.


You pass this array to the table view in your table view delegate, by implementing the tableView(_:editActionsForRowAt:) method. That's where you'll create the

UITableViewRowAction objects and return the array.


Does that help?

Accepted Answer

You need to provide an array of UITableViewRowAction objects, one per action you want the table rows to offer. (AFAIK you don't have to implement the swiping part yourself.) This is not additive, so when you provide this array it replaces the default behavior, and you must contain all the possible actions you want.


You pass this array to the table view in your table view delegate, by implementing the tableView(_:editActionsForRowAt:) method. That's where you'll create the

UITableViewRowAction objects and return the array.


Does that help?

Thanks for the quick reply Quincy. That makes perfect sense. I still have to test it but now I know what to do! THANKS SO MUCH MAKING SENSE IN ALL THIS!!

UITableViewRowAction in simple terms
 
 
Q