开发者

How to ask confirmation before deletion with a table

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 confi开发者_如何学Gormations 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜