Everyone needs a good editor..!!!âď¸
Since iOS 8, Apple has provided us with the provision to add our own customized actions to a U_ITableViewâs_ rows using the U_ITableViewDelegate_ methodââât_ableView(_:editActionsForRowAt:)._
tableView(_:editActionsForRowAt:)
Asks the delegate for the actions to display in response to a swipe in the specified row.
Use this method when you want to provide custom actions for one of your table rows. When the user swipes horizontally in a row, the table view moves the row content aside to reveal your actions. Tapping one of the action buttons executes the handler block stored with the action object.
Now that iOS 11 is here, we have some new additions đ¤ to the table viewâs editing API. Letâs see whatâs in it for us.đ
Whatâs new in iOS 11?
With the release of iOS 11, Apple introduced two new methods đŽ for handling Swipe Actions in UITableView to support swipe actions on both leading as well as trailing edge of the row, i.e.
- tableView(_:leadingSwipeActionsConfigurationForRowAt:)âââswipe actions to display on the leading edge of the row
- tableView(_:trailingSwipeActionsConfigurationForRowAt:)âââswipe actions to display on the trailing edge of the row
These methods were introduced as a part of UITableViewDelegate.
Swipe ActionsâââOptional
The methods to handle swipe actions in iOS 11 are optional đ , i.e.
- if implemented, supersede the tableView(_:editActionsForRowAt:) delegate method.
- if not implemented, tableView(_:editActionsForRowAt:) will be called as the default behaviour.
Swipe ActionsâââFull Swipe
In iOS 11, swipe actions appear as Full Swipe by default đ¤, i.e the swipe spans the complete width of the UITableView.
The Full Swipe behaviour can be configured using performsFirstActionWithFullSwipe property đ, introduced as a part of UISwipeActionsConfigurationâââThe set of actions to perform when swiping on rows of a table.
When this property is set to true, a full swipe in the row performs the first action listed in the actions property. The default value of this property is true.
Promotions
Donât forget to read my other articles:
- Everything youâve always wanted to know about notifications in iOS
- Drag It & Drop It in Collection & TableâââiOS 11
- Everything about Codable in Swift 4
- Color it with GRADIENTSâââiOS
- All you need to know about Today Extensions (Widget) in iOS 10
- UICollectionViewCell selection made easy..!!
Feel free to leave comments if you have any doubts. đđ