UIDocumentInteractionController 将自定义操作添加到菜单(例如电子邮件、保存到照片)
我已经开始在新应用程序中使用 UIDocumentInteractionController,但我想知道如何向预览屏幕上显示的操作菜单添加其他操作?
菜单似乎只列出了已注册给定 url 类型的应用程序,而且我看到 iOS4.2 上显示了 PRINT。我想添加通过电子邮件发送并保存到照片,但没有看到扩展此菜单的方法。我可以编写我想要的操作,好吧,只是将它们添加到菜单中,这似乎是不可能的?
我错过了一些明显的东西吗?
I've started using UIDocumentInteractionController for a new app but I'm wondering how to add additional actions to the action menu that you get on the preview screen?
It seems that the menu only lists apps that have registered for a given url type plus I'm seeing PRINT showing up on iOS4.2. I would like to add send by email and save to photos but don't see a way of extending this menu. I can code the actions I want OK, it's just adding them into the menu that seems impossible?
Am I missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你是对的,
这些是方法
这些方法支持的操作选择器是 copy: 和 print:。
You are correct,
These are the methods
The supported action selectors for these methods are copy: and print:.
我还不能发表评论,所以我来回答:-)
你应该尝试一下 QuickLook 框架。就我而言,我搜索了所有如何自定义 UIDocumentInteractionController 的方法,但没有找到任何有用的东西。我使用 QuickLook 实现了我想要的目标(在我的例子中,在另一个视图中具有预览“视图”)。这是一个示例代码,将 QLPreviewController 作为子控制器(能够自由创建父控制器,这将在您的情况下完成任务)。
您还需要一些委托:QLPreviewControllerDataSource 和 QLPreviewControllerDelegate
,还需要实现一些委托:
将 NSURL 返回到资源
,返回要预览的项目数(在我的例子中为 1)
I cannot comment yet so I'm answering instead :-)
You should give QuickLook framework a try. In my case, I searched all over how to customize UIDocumentInteractionController and failed to find anything useful. I achieved what I wanted (in my case, having a preview "view" inside another view) using QuickLook. Here's a sample code, to have a QLPreviewController as a child controller (being able to create the parent controller freely, which will do the trick in your case).
You will also need some delegates: QLPreviewControllerDataSource and QLPreviewControllerDelegate
and also some need to implement:
return NSURL to the resource
return the number of items to preview (in my case, 1)
要显示电子邮件和“保存到”选项,您应该使用
或
如 UIDocumentInteractionController.h 中所述:
使用时
或
不显示电子邮件、短信和“保存在照片/视频中”。
如果需要其他无法识别的操作,请考虑使用 UIActionSheet。
To display email and 'save to' options you should use
or
As described in UIDocumentInteractionController.h :
While using
or
email, sms and 'save in photo/video' are not displayed.
If other actions are required that are not recognized, consider using UIActionSheet.
如果您在 iPad 上使用带有应用程序的表格视图,并且可以手动添加打印、电子邮件和其他所有内容,我可以建议您使用简单的 UIActionSheet 或更好的弹出窗口。
i could suggest a simple UIActionSheet or better a popover if you are on iPad with inside a table view with apps and you can manually add Print,email and everything else.