How to edit tableview cell on TAP instead of swipe – Swift
I have a
UITableViewController and at the moment, the user can swipe left on the cell to reveal an ‘add to favourites’ button. I would now like to add an icon to the cell that the user can tap to reveal the this button (does the same thing as swiping to the left). This will just act as a visual aid for the users who do not know swiping left will do the same thing.
TableView, I use the following code to ‘close the cell’ when the user has pressed the button:
itemsTableView.setEditing(false, animated: true)
From this I assumed that to manually open the cell I would simply call:
//Get cell let cell:TableViewCell = itemsTableView.cellForRowAtIndexPath(NSIndexPath(forRow: sender.tag, inSection: 0)) as! TableViewCell //Open cell to reveal button cell.setEditing(true, animated: true)
Unfortunately this does not work. So I would like to know what is the function that is called when a user swipes to the left of a cell and how can I replicate it when a user taps on the icon?
- Maintain UITableViewCell background color when going into edit mode
- how do I calculate heightForRowAtIndexPath when the cell is not even constructed yet?
- custom UITableView header similar to UISearchBar
- How can I change the font size of my UITableView cell title?
- UITableView Edit mode
- UITableViewCell with custom gradient background, with another gradient as highlight color
Solutions Collect From Internet About “How to edit tableview cell on TAP instead of swipe – Swift”
I don’t think you’re going to be able to do it, sorry. This feature relies on the UITableView’s pan gesture recognizer. When the user pans sideways, the table view checks the
editActions... delegate method and, if we have edit actions, inserts a private confirmation view behind the cell and allows the cell to be moved to reveal it. You can’t trigger that behavior programmatically as far as I can tell.
This would be a reason — one of many very good reasons — for sticking with a third-party scrollable cell class. In this way, the cell is a horizontal scroll view and you just scroll it in code.
- How to show an HTML string on a UILabel in iOS?
- iOS Autolayout Vertically equal space to fill parent view
- iOS App testing: No Code signature found
- How to Dismiss a Storyboard Popover
- How to change UITabBar Selection color
- How to authenticate iOS/iPhone users with remote web application and re-use authentication ticket in future requests to the same web application?
- objective c UITableView not scrolling smooth with custom cell & views
- How can I Pause a NSOperation in a NSOperationQueue?
- WKWebView equivalent for UIWebView's scalesPageToFit
- Objective C – Declaration Error – please explain
- what is kCFErrorDomainCFNetwork Code=303
- How to add UILongPressGestureRecognizer to a UITextField?
- LLDB equivalent of gdb “directory” command for specifying source search path?
- Drag Rotate a Node around a fixed point
- Display UIView Above Apple Status Bar in iOS 8