如何根据人机界面指南在iPad上进行删除确认

发布于 2024-10-10 11:50:19 字数 650 浏览 0 评论 0 原文

通读 iOS人机界面指南,似乎没有“正确”的方法让用户在删除之前确认。该指南列出了处理 UIAlertView 和 UIActionSheet 时的 3 件事:

  • 不要使用警报视图来确认用户启动的操作。
  • 不要在操作表(iPad 上)上包含“取消”按钮。
  • 操作表必须至少有 2 个按钮。

所以...我需要让用户确认他们想要删除某些内容。向他们展示的唯一选择是实际删除该内容,或者什么都不做(取消)。他们可以通过单击操作表外部来选择不执行任何操作,从而将其关闭。但这只为操作表留下 1 个按钮。您应该如何进行删除确认?

在 iPhone 上,有模态/动画版本的操作表非常适合此目的。但 iPad 彻底改变了操作表的呈现方式。该文档表示,您仍然可以通过用动画来呈现 iPad 上的操作表作为模态;但我发现无论动画是“是”还是“否”,它的外观和行为都完全相同。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迟月 2024-10-17 11:50:19

我的应用程序中有一个“取消下载”UIActionSheet,我会弹出它来确认取消下载。我这样展示:

UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:nil 
                                                    delegate:self 
                                           cancelButtonTitle:nil 
                                      destructiveButtonTitle:@"Cancel downloads" 
                                           otherButtonTitles:nil];
[action showFromRect:self.cancel.frame inView:self animated:NO];
[action release];

其中 self.cancelUIToolbar 中的 UIButton。这与照片应用程序中的“删除”确认具有相同的效果。如果苹果公司为他们的软件这样做,我认为我的软件也可以......

希望这有帮助!

I have a "Cancel downloads" UIActionSheet in my apps that I pop up to confirm, well, canceling downloads. I show it like this:

UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:nil 
                                                    delegate:self 
                                           cancelButtonTitle:nil 
                                      destructiveButtonTitle:@"Cancel downloads" 
                                           otherButtonTitles:nil];
[action showFromRect:self.cancel.frame inView:self animated:NO];
[action release];

where self.cancel is a UIButton in a UIToolbar. 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!

墨小沫ゞ 2024-10-17 11:50:19

点击 UIActionSheet 与取消它相同。由于 UIActionSheet 只是位于调用它的选项之上(通常指向)的一个小窗口,因此它不会引起用户的注意。因此,在这种情况下,假设的直观操作是敲击 UIActionSheet 以使其消失。所以这相当于一个取消按钮(根据含糊的文档,为什么你“有时”不需要另一个按钮)。

UIActionSheet 文档页面

在 iPad 上呈现操作表时,有时不应包含取消按钮。如果您仅呈现操作表,系统将在弹出窗口内显示操作表,而不使用动画。由于点击弹出窗口外部会关闭操作表而不选择项目,因此这会导致取消操作表的默认方式。因此,包含取消按钮只会引起混乱。但是,如果您有现有的弹出窗口并使用动画在其他内容之上显示操作表,则取消按钮仍然合适。有关详细信息,请参阅 iOS 人机界面指南。

如果您实现 actionSheet:clickedButtonAtIndex: 方法,点击 UIActionSheet 将返回按钮索引 -1。其他按钮从索引 0 开始。

我认为要点是 Apple 指南在某些情况下不一致或不可能。但从文档的语言和我对 HIG 的阅读来看,您应该尝试满足有意义的条件,如果它在您的实现中没有意义,则不要过多担心。

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:

When presenting an action sheet on an iPad, there are times when you should not include a cancel button. If you are presenting just the action sheet, the system displays the action sheet inside a popover without using an animation. Because taps outside the popover dismiss the action sheet without selecting an item, this results in a default way to cancel the sheet. Including a cancel button would therefore only cause confusion. However, if you have an existing popover and are displaying an action sheet on top of other content using an animation, a cancel button is still appropriate. For more information see iOS Human Interface Guidelines.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文