类似于 iOS 7 Safari 的 UIActionSheet-like 控件

Posted

技术标签:

【中文标题】类似于 iOS 7 Safari 的 UIActionSheet-like 控件【英文标题】:UIActionSheet-like control similar to iOS 7 Safari's 【发布时间】:2014-01-03 00:34:40 【问题描述】:

我正在尝试创建一个类似于 Safari 的 UIActionSheet。我无法在 Apple 文档中找到有关如何使 UIActionSheet 看起来像这样的任何内容。是否有我缺少的控件/API 可以用来创建下面的内容,还是我坚持创建自己的 UIView 并显示它?

Ninja Edit:这似乎是一个 UIActivityViewController。有什么方法可以添加我自己的自定义操作吗?

【问题讨论】:

我不认为这是一个常规的行动表——它是某种共享表,不是吗? 【参考方案1】:

这不是 UIActionSheet。

它是一个 UIActivityViewController:

https://developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html

来自 Apple 的文档:

The UIActivityViewController class is a standard view controller that you can use to offer
various services from your application. The system provides several standard services,  
such as copying items to the pasteboard, posting content to social media sites, sending 
items via email or SMS, and more. Apps can also define custom services.

Your app is responsible for configuring, presenting, and dismissing this view controller.
Configuration for the view controller involves specifying the data objects on which the 
view controller should act. (You can also specify the list of custom services your app 
supports.) When presenting the view controller, you must do so using the appropriate means
for the current device. On iPad, you must present the view controller in a popover. On 
iPhone and iPod touch, you must present it modally.

【讨论】:

【参考方案2】:

关于ninja edit:是的,您可以向 UIActivityViewController 添加操作。

请参阅Apple's doc, 或 this SO question 上的 UIActivity。

【讨论】:

以上是关于类似于 iOS 7 Safari 的 UIActionSheet-like 控件的主要内容,如果未能解决你的问题,请参考以下文章

Safari(移动)IOS - 单击外部时输入不会失去焦点

Phonegap iOS Safari 调试工作流程

iOS URL Scheme,完成后返回 Safari

iOS 7 UITableViewController 导航类似于 iOS 6

如何实现一个可编辑的 UITableView,类似于 Safari 书签?

我们如何获得类似于 ios 6 的 ios 7 的分组 UITableview 样式