How to enable both swipe to delete and a delete button made in edit mode in UITableView - ios

By default edit mode is on, that's why swipe on cell, it will delete like this, and when click on edit following method use to delete the data
Right now it works correctly but either one of them is going to use. I want to use both method for delete cell.
Please help me to find some code snippet or tutorial link

The natural iOS behaviour for Edit mode in a UITableView is just showing the '-' button for deletion, thats the way I recommend you to use, because of the users are use to deleting on that way.
With this library, you can assign custom buttons and actions for both Swipe directions. Maybe with it you can achieve what you want.
https://github.com/MortimerGoro/MGSwipeTableCell
I would try to add a custom right UIBarButton with a custom action, and after it get pressed, you can try to force swiping the cell to both directions, and showing the buttons you want.

Related

Is it possible to change default delete action Icon in UITableView edit mode?

I would like to set custom icons for the UITableView delete icon for the table's edit mode.
I found a way of doing it by setting UITableViewCellEditingStyleNone in editingStyleForRowAtIndexPath method ant then adding my custom button view in the place where that icon should be by subclassing UITableViewCell. source (enter link description here)
I set up a delegate to get the tap even from that button, but with this approach when I tap on this custom button I can't get the cell to slide to the left to reveal red delete button (see the image). So this way, I can just delete the cell by taping only once.
What I need is to mimic the same standard deletion flow with two taps(first on the left delete icon, second on the delete button the slides to the left) but also have my custom icon for the delete on the right.
Is this possible to do?
Any kind of help is highly appreciated.
For fully customize UITableViewcell https://github.com/CEWendel/SWTableViewCell
It will Help you a lot

UITableViewCell Show editactions programmatically

I am hoping there is a way to programmatically display the swipe left edittask list for a given cell. I tried everything I could think of to get it to display but nothing seems to work.
I am able to show them with a swipe left without issue but I need the ability to show them programmatically.
How to accomplish this?
Try setting editing on the cell. According to this from Apple, it should display the edit actions.

UITableView loses selection after swipe

I have a problem with the UITableView selection. If I swipe to show the Delete button, and then I tap somewhere else to cancel it, I loses the current selection.
How can I retain my selection by the Table even having done that, or at least know if the Delete button is being dismissed (so that I can manually re-select it)?
That is the default swipe to delete behaviour. There isn't any clean ways to retain the selection after you scroll.
It sounds like what you're trying to do is just to remember a cell selection? In that case, you will need to override the swipe gesture and add your own method. You can store this information any way you like.
As an example, you can check out this project that shows how to handle selections.

change order of list in tableview by clicking on whole cell

I currently have a 'tableview' with a list of items and I have enabled an 'edit' button to go into edit mode which shows the 'reordering controls' on the right side of the screen. I have also enabled 'canMoveRowAtIndexPath' and 'moveRowAtIndexPath:toIndexPath' to allow for the user to hold and drag the reorder control on the right side to reorder the list and have the data model update.
Is there a way to enable this but allow the user to click and drag the whole cell and not only the 'reorder controller'? Essentially I want to enlarge the area of the reorder controller's function to the whole cell when tableview is in editing mode.
for anyone else who is interested, I used this guide to get it working: b2cloud
the starting code template does not work as optimally since it has nib files and I'm using Xcode5 but it still works. The important code is all in the actualy tutorial as he lists how to set the reorder control to the size of the size via inserting it as a subview.
There is a way to enable this that allow the user to click and drag the whole cell and not only the 'reorder controller'!
Please check it out: https://github.com/FlorianMielke/FMMoveTableView
This might be helpful to you, Sir :)

How can you get the delete confirmation button to show up on UITableViewCell if you tap the cell?

I have implemented a UITableView to allow the standard delete button to show up on the far right of a cell when the user swips over it. I have a use case where I want to show this same delete button when a user taps on a cell.
I am able to handle the tap in the delegate method didSelectRowAtIndexPath, but I can not figure out how to show the delete button. I have found a lot of references on how to show the delete icon on the left of the cell, but not for the delete button that shows up when you normally swipe. Is there a way to do this, or do I need to create my own custom button?
I'm afraid there is no way to do this. You could simulate touches making a swipe, but that'd involve using private APIs. You will have to manually create your own delete button.

Resources