Add one more UITableViewRowAction when cell already shows two - ios

I'll talk about UITableViewRowAction which is availeble from iOS 8. I need to made 2 things
When user swipes left show 2 UITableViewRowActions (delete and favorite)
This one Im already made buy adding 2 UITableViewRowActions in
tableView: editActionsForRowAtIndexPath:
When the user taps to "delete" row action which is already shows - I need to show one more row action (confirmation)
I have no mind how to add row action from row action handler...
Sorry for bad English.
Thanks.

I think this is impossible. Adding a row action dynamically requires reloading the tableview, and this would require the user to swipe to the left again. You then would need to set a property (waitingForConfirmation = true), and then add the rowAction in editActionsForRowAtIndexPath if the property is set to true. This will not be user friendly at all, and I do not view it as a valid solution.
The best solution would probably be to show a UIAlertController and then ask the user to confirm, and run the required code afterwards by adding the code in the completion handler of the button.

Related

Turn off delete confirmation in table view cell after tap on the deletion control

In my tableView I use editing mode for deleting and inserting rows. When I tap on delete, the "delete" button appears on the right of the cell. I want to delete the cell immediately without confirmation.
Is there any way to turn off this delete confirmation after tapping on deletion control?
I want to remove this delete confirmation button.
Unfortunately I didn't find any good native solution for this problem. I solved this problem by custom UIButton which I placed in my custom uitableViewcell, which triggers deletion of the row.

Can I choose only portion of a row in UITableView to be clickable(selectable) in Swift?

So I have a table in the accordion style. When a row is clicked, five radio buttons are displayed. Then, users should be able to click on those buttons. It successfully displays the buttons, but when the buttons are clicked, instead of highlighting the selected button, it shrinks the row itself. I think this is probably because I implemented each set of the label part and the option part as a single row, just in different UIViews. I believe clicking on the view that contains buttons is overridden by clicking on the row(label + options). Its really hard to explain, but I think a solution could be restricting selectrow action of the table to only certain portion of the row.
Is there a way I could achieve this? If I cannnot, is there other ways to implement the accordion table to be used as I described?
I am having a really hard time trying to explain this. If you have any questions, please let me know.
table
As per my understanding you van give a try to below steps:
Disable the row selection so that you can avoid row selection. Usecell.selectionStyle = .none
Secondly for your button in row set the IBAction in controller class and in Storyboard connect those actions to specific buttons.

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

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.

How to set tag to a Button in Apple Watch

I am trying to image gallery in apple watch. I am putting a table with two buttons in a row. So for selection of image I need to set tag to a button.
Can we do it in watch kit.
Whilst you can't set a tag on the buttons there are a couple of way you can achieve what you're after. From what I can establish from your comment you have a table with a custom row controller in it, and in each row you have 2 buttons?
As you can't tag the buttons you could assign the method they call to individual methods defined in your custom row controller. That will give you which button was pressed. To find out the index of the row controller, you could expose a variable in the header of your row controller and set that with the value that you would have used as a tag when populating the table. The button methods will be calling the method in the instance of the row controller so the variable is in scope.
The following link helped me build my table based app for WatchKit: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/Tables.html
There is no option for tag. There is one trick with the help of this trick you can identify like this
if ([[btn titleForState:UIControlStateNormal] caseInsensitiveCompare:#"YES"] == NSOrderedSame)// set your button's current state for which state you set title
{
NSLog(#"%# button pressed.",[btn titleForState:UIControlStateNormal]);
}
Set Button Title on Watch Kit
Btn.setTitle("BtnTitle")
https://developer.apple.com/library/ios/documentation/WatchKit/Reference/WKInterfaceButton_class/#//apple_ref/occ/instm/WKInterfaceButton/setTitle:

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.

Resources