Welcome, Guest
Username Password: Remember me

UIActionSheet Delete Confirmation
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: UIActionSheet Delete Confirmation

UIActionSheet Delete Confirmation 1 year, 5 months ago #1

Hi All,

To set the scene, when a user taps the Edit button on my table view the edit controls appear. They can then tap the deletion control (red circle to the left of the cell) to display the "Delete" button, allowing them to delete the cell. When the user taps the "Delete" button it goes darker (i.e. indicating that the button has been selected) and a UIActionSheet appears to confirm the deletion (and provides the user with a few other implementation-specific options).

If the user dismisses the UIActionSheet through a non-destructive button (e.g. the Cancel button or alike), which results in the cell not being deleted, they are back at the table view with the Delete button still displayed in the darker (selected) state. Is there a way to get the Delete button back to its unselected state, as aesthetically it doesn't look very good. Tapping the deletion control to hide and then re-show the Delete button does not fix the problem either (albeit that was more for testing purposes, as I need a programmatic solution the problem).

The way that I am showing the UIActionSheet is overriding - (BOOL)tableViewModel:(SCTableViewModel *)tableViewModel willRemoveRowAtIndexPath:(NSIndexPath *)indexPath to initialise and display the UIActionSheet and then returning NO, so the cell is not deleted at this point. I then manually call the deletion (if necessary, depending on which button in the UIActionSheet was tapped) in the - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex delegate method.

Hope that this makes sense! It is really a minor bug, but very annoying that I haven't been able to solve it, so any suggestions would be greatly appreciated

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: UIActionSheet Delete Confirmation 1 year, 5 months ago #2

Hi Matthew,

Thanks for the detailed explanation!

Just please make sure you call "[tableViewModel.modeledTableView reloadRowsAtIndexPaths:...]" for the row in question if you will not delete it. Please tell me if you still need help with this.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: UIActionSheet Delete Confirmation 1 year, 5 months ago #3

Hi Tarek,

Thanks for your quick reply However, will calling the [tableViewModel.modeledTableView reloadRowsAtIndexPaths:...] method result in the Delete button being hidden in a non-animated fashion (because it is just reloading the row and thus will default back to its original state)? If you user cancels the deletion in the UIActionSheet I would like the Delete button to remain displayed, just in the unselected state.

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: UIActionSheet Delete Confirmation 1 year, 5 months ago #4

Hi Tarek,

Just following-up with a bit more information. I tried your suggestion of calling the [tableViewModel.modeledTableView reloadRowsAtIndexPaths:...] method. However, this does (as the name suggests) reload the entire cell resulting in the Delete button disappearing and the deletion control returning to its original state with no animation, so the transition looks a bit sudden and not very graceful.

When the UIActionSheet is dismissed with a non-destructive button I would like the cell to remain exactly how it appeared when the Delete button was originally tapped (i.e. the Delete button visible with the deletion control in the "open" position) but just for the Delete button to return to its lighter, unselected state.

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: UIActionSheet Delete Confirmation 1 year, 5 months ago #5

Hi Tarek,

Me again, with another question to add onto this thread I have been continuing to work on the deletion functionality, as I figured that I could slot in the fix for the Delete button state once we come up with something, but I have encountered another problem.

The purpose of the UIActionSheet is to provide a final confirmation that the user does want to delete that row. I've got all that appearing correctly but cannot figure out how to actually delete the row when the user taps the destructive "Delete" button on the UIActionSheet. In the actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex delegate method I called the [objectsSection dispatchRemoveRowAtIndexPathEvent:...] method. However, I quickly found that this dispatch method calls the tableViewModel:(SCTableViewModel *)tableViewModel willRemoveRowAtIndexPath:(NSIndexPath *)indexPath method, where I am returning NO and doing the original call to initialise and display the confirmation UIActionSheet. This results in a loop of sorts - when I tap the "Delete" button the willRemoveRowAtIndexPath: method is called again which then shows the UIActionSheet again and so fourth.

So, to cut a long story short, how should I go about actually deleting the row in code? I'm happy to make modifications to any necessary methods, but I am going in circles a bit here at the moment

Thanks again for your help!
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: UIActionSheet Delete Confirmation 1 year, 5 months ago #6


when I tap the "Delete" button the willRemoveRowAtIndexPath: method is called again which then shows the UIActionSheet again and so fourth.


Thanks a lot Matthew for reporting this! We've fixed this issue, I'll send you our latest update right away.


calling the [tableViewModel.modeledTableView reloadRowsAtIndexPaths:...] method result in the Delete button being hidden in a non-animated fashion (because it is just reloading the row and thus will default back to its original state)? If you user cancels the deletion in the UIActionSheet I would like the Delete button to remain displayed, just in the unselected state.


I am unsure that you can do that after the user taps the delete button. This actually has nothing to do with STV, you will face the same limitation if you're using a normal UITableView. I did some research and the only post I found that remotely discusses something similar to this is here: stackoverflow.com/questions/2334320/wipe...t-of-table-view-cell . So it seems that the only thing you could do is remove the delete button after the validation fails. Does anyone else have any feedback on this?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 1.75 seconds