gpt4 book ai didi

objective-c - 在 iPad 上使用 UIActionSheet

转载 作者:太空狗 更新时间:2023-10-30 03:14:59 24 4
gpt4 key购买 nike

Apple 的 UIActionSheet 文档让我感到困惑。首先,在 iPad 人机界面指南中,它说:

To learn more about using an action sheet in your code, see “Using Popovers to Display Content” in iPad Programming Guide.

但是在“使用弹出窗口显示内容”部分,它根本没有提到操作表!我在这里遗漏了什么吗?

http://developer.apple.com/library/ios/#documentation/General/Conceptual/iPadHIG/UIElements/UIElements.html#//apple_ref/doc/uid/TP40009446-CH6-SW9

我的主要问题是:在 iPad 上,UIPopoverController 和 UIActionSheet 有什么区别?如果 UIActionSheet 自动出现在 UIPopoverController 中,是否有任何理由使用 UIActionSheet?我看到它的委托(delegate)和按钮的自动创建如何减少代码行,但从可用性 POV 来看,有区别吗?

此外,用动画显示我的 actionSheet 根本不起作用。它的外观和行为与没有动画的 actionSheet 完全一样(就像我只使用 UIPopoverController 而根本没有 actionSheet 一样)。这是我的代码:

UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"An unsaved property already exists. You must assign a name to this property before creating a new property. Would you like to:"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:@"Overwrite"
otherButtonTitles:@"Open unsaved property", nil];

[action showFromRect:CGRectMake(0, 0, 200, 200) inView:self.mainSplitViewController.view animated:NO];

我如何获得看起来像 Apple 文档中示例动画 actionSheet 的 actionSheet(从 map 应用程序,您可以在其中向联系人添加位置)?

我可能最终会为此使用警报而不是弹出窗口或 actionSheet,但理解这一点仍然很有用。

谢谢!

最佳答案

首先,UIActionSheetUIPopoverController 之前就已存在,而 UIPopoverController 在 iPhone 上不可用,因此它对于向后兼容和通用应用程序很有用.

此外,UIActionSheet 不一定显示在弹出窗口中,特别是如果您从 UIBarButtonItemUIToolbar 显示它已经在弹出框内。然后以与 iPhone 类似的方式呈现(从 View Controller 底部滑入)。根据 HIG,你不能同时显示多个弹出窗口(我曾经有一个应用程序因此被拒绝),所以如果 View Controller 可能在弹出窗口内(比如在标准的 Split View应用程序中),你可能如果可能,想使用操作表。当然,在很多情况下您不能用操作表替换弹出框,因为操作表只显示按钮列表和标题,而弹出框可以显示任何 View Controller 。

我认为 animated 参数仅在操作表以“经典”(如在 iPhone 上)方式呈现时才有效。

关于objective-c - 在 iPad 上使用 UIActionSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4078871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com