iPad 上的 UIActionSheet 不显示取消按钮

发布于 2024-11-07 21:19:33 字数 494 浏览 0 评论 0原文

我试图在 UIActionSheet 中显示取消按钮,但它没有显示,这是可接受的行为吗?请指教。

UIActionSheet *actionSheet = [[UIActionSheet alloc]
          initWithTitle:@"Are you sure you want to clear the cache?"
          delegate:self
          cancelButtonTitle:@"No"
          destructiveButtonTitle:@"Yes"
          otherButtonTitles:nil];

[actionSheet showInView:self.view];  

[actionSheet release];

I am trying to show cancel button in UIActionSheet but it's not showing, is that an acceptable behavior? please advice.

UIActionSheet *actionSheet = [[UIActionSheet alloc]
          initWithTitle:@"Are you sure you want to clear the cache?"
          delegate:self
          cancelButtonTitle:@"No"
          destructiveButtonTitle:@"Yes"
          otherButtonTitles:nil];

[actionSheet showInView:self.view];  

[actionSheet release];

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

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

发布评论

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

评论(1

原来分手还会想你 2024-11-14 21:19:33

iPad 对于操作表及其取消按钮有一些特殊规则,具体取决于您显示它的位置:

您可以从工具栏、选项卡栏、按钮栏项目或视图中呈现操作表。在确定如何呈现操作表时,此类会考虑起始视图和当前平台。对于在 iPhone 和 iPod touch 设备上运行的应用程序,操作表通常从拥有视图的窗口底部向上滑动。对于在 iPad 设备上运行的应用程序,操作表通常显示在以适当方式锚定到起始视图的弹出窗口中。点击弹出窗口外部会自动关闭操作表,就像点击任何自定义按钮内一样。您也可以通过编程方式关闭它。

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

以下是更多说明的链接:http://crazyviraj.blogspot。 com/2010/05/showing-cancel-button-in.html

iPads have some special rules about action sheets and their cancel buttons, depending on where you are displaying it from:

You can present an action sheet from a toolbar, tab bar, button bar item, or from a view. This class takes the starting view and current platform into account when determining how to present the action sheet. For applications running on iPhone and iPod touch devices, the action sheet typically slides up from the bottom of the window that owns the view. For applications running on iPad devices, the action sheet is typically displayed in a popover that is anchored to the starting view in an appropriate way. Taps outside of the popover automatically dismiss the action sheet, as do taps within any custom buttons. You can also dismiss it programmatically.

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 iPad Human Interface Guidelines.

Here's a link with more explanation: http://crazyviraj.blogspot.com/2010/05/showing-cancel-button-in.html

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