1

I have a tableview and when the user swipes I want to ask them if they are sure they want to delete it.

What I've tried is in my DataSource class, in the CommitEditingStyle, I check for the UITableViewCellEditingStyle.Delete and if that's what happening, then I want to present a UIAlertView (if the user has selected this preference). I can Show the AlertView without a problem, and I include an instance of the AlertViewDelegate class I created, but if I click either the Cancel or OK buttons, everything crashes. I thought maybe I needed to invoke this on the MainThread, so I've tried that, but no success there.

The code I have when the OK button is clicked is simple, it calls the DeleteStuff method I have on the datasource class (I pass a reference to the datasource), which allows for the deleted row to fade and everything to happen as if their preference was no confirmations to be presented.

The delete is invoked by the user swiping the row of the table and then clicking the standard delete button.

I figure there's something key that I'm missing.

Driss Zouak
  • 2,381
  • 2
  • 26
  • 39
  • 1
    You should be using a UIActionSheet for confirming a dangerous action, not a UIAlert. Please see Apple's Human Interface Guidelines. See also this SO question: http://stackoverflow.com/questions/4598043/how-to-do-delete-confirmation-on-ipad-according-to-the-human-interface-guidelines – occulus Mar 14 '11 at 17:32
  • @occulus, sadly I never received a satisfactory answer to that question. – GendoIkari Mar 14 '11 at 17:35
  • what's the error? Post the actual delete code that you have... – GendoIkari Mar 14 '11 at 17:35
  • The error was a NullReference officially, but it pointed to the Main.cs. I've taken the advice to flip it to an ActionSheet and it works great. Thanks everyone. – Driss Zouak Mar 14 '11 at 19:07

1 Answers1

1

Without seeing your code it's almost impossible to tell what's wrong. However, for your information, you may want do this stuff using an UIActionSheet instead of an UIAlertView. Just set the UIActionSheet delegate to self, and handle the user's tapping a button in the UIActionSheet delegate methods. It works like a charm, never experienced a problem.

Massimo Cafaro
  • 25,429
  • 15
  • 79
  • 93