Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 184.108.40.206 release ready!
In this article, we will discuss how to select multiple items using Pan Gesture.
Recently Apple has announced that we can select the multiple rows in table view using two fingers.
It would be easy and cool to select rows by simply select and drag. We would implement this using the Pan gesture. Selecting multiple items using Pan Gesture requires iOS 13 and above. Let’s move to the article.
Firstly, we need to set up our table view. Just create a table view assign delegate and dataSource to table view and implement the functions of the Table view protocol.
Now we have set up the basic configuration for select multiple items using Pan gesture. After that, we would require the data to populate the table view rows. We have created a model with variables var name and var isRowSelected.
For enabling multiple selections during editing we should set allowsMultipleSelectionDuringEditing property of the table view to true in viewDidLoad()
We have created an array that holds the dataModel values as var model = [dataModel]()
Now it’s time to assign the values to the array as:
Call the setDataIndataModel function in viewDidLoad()
Above all, we will write the table view protocol functions that are used to implement multiple selections. Here is the code:
I will start by listing the necessary methods of table view delegate to implement the multiple select using two-fingers. After that, I will explain the methods listed below.
shouldBeginMultipleSelectionInteractionAt method allows users to use two-finger select when set to true.
In didBeginMultipleSelectionInteractionAt method we need to set the setEditing property to true. In other words, we allow the table view to edit the rows.
tableViewDidEndMultipleSelectionInteraction method is called when the editing of the table view rows ends. In other words, when the user stops the two-finger pan gesture.
didSelectRowAt gives the value of the selected row. We are checking if the row is selected otherwise, we are toggling the value of the model array for the isRowSelected variable.
didDeselectRowAt method works opposite to didSelectRowAt. For instance, if the user deselects the row then we change the value of isRowSelected
In addition, click here for the Apple documentation.
We hope you would like my article.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
All communication is done through a ticket system. I appreciate the regular almost daily updates of what is being worked on, and communicating changes or updates is easy through this system. Mobikul's response timeframe is quick.
Owner, Shop ATV Escape
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.