Reading through the iOS Human Interface Guidelines, it appears that there is no "right" way to have the user confirm before deleting. The Guidelines list 3 things when dealing with UIAlertView and UIActionSheet:
- Do not use an alert view to confirm a user-initiated action.
- Do not include a "cancel" button on an action sheet (on the iPad).
- An action sheet must have at least 2 buttons.
So... I need to have the user confirm that they want to delete something. The only choices to present them with is to actually delete the thing, or do nothing (cancel). They can choose to do nothing by clicking outside the actions sheet, which dismisses it. But this only leaves 1 button for the action sheet. How are you supposed to do a delete confirmation?
On the iPhone, there is the modal / animated version of the action sheet which works great for this purpose. But the iPad completely changes the way action sheets are presented. The documentation says that you can still present an action sheet on the iPad as modal by presenting it with animation; but I have found that it looks and acts exactly the same whether animated is YES or NO.
Tapping off of the UIActionSheet is the same as canceling it. And since the UIActionSheet is only a smallish window over top of (and usually pointing at) the option that called it, it doesn't own the user's attention. So the assumed intuitive action in that case is taping off of the UIActionSheet to make it go away. So that equals a cancel button (and why you "sometimes" don't need another one, according to the vague documentation).
From the UIActionSheet documentation page:
If you implement the actionSheet:clickedButtonAtIndex: method, tapping off of the UIActionSheet will return a button index of −1. Other buttons start at an index of 0.
I think the takeaway is that the Apple guidelines are inconsistent or impossible in some scenarios. But it seems from the language of the documentation and my reading of the HIG that you should try to satisfy the conditions that make sense and not sweat it too much if it doesn't make sense in your implementation.
I have a "Cancel downloads"
UIActionSheet
in my apps that I pop up to confirm, well, canceling downloads. I show it like this:where
self.cancel
is aUIButton
in aUIToolbar
. This gives the same effect as the "Delete" confirmation in the Photos app. If Apple does it for their software, I figure it's all right with mine...Hope this helps!