问题描述
我正在尝试将我的应用程序移动到使用 UIActivityViewController,而不是 UIActionSheet,以便我获得精美的图形共享按钮而不是文本按钮.(我的应用仅针对 iOS 6.)
I'm trying to move my app to use UIActivityViewController, rather than UIActionSheet, so that I get the fancy graphical sharing buttons rather than the textual buttons. (My app is targeted at iOS 6 only.)
在尝试使用它几个晚上之后,似乎我完全误解了如何使用它,或者 Apple 当前的实现很糟糕:
After trying to work with it for a couple nights, it seems either I am totally misunderstanding how to use it, or the current implementation by Apple is terrible:
您不能为不同的服务指定不同的消息.如果我想要一些适用于:邮件、Facebook、消息和 Twitter 的内容,则最多需要 140 个字符才能在 Twitter 上使用.有没有办法为每种类型的活动设置自定义内容?
You can't specify a different message for different services. If I want something that will work across: Mail, Facebook, Messages AND Twitter, it's going to need to be 140 characters max, to work on Twitter. Is there a way to set custom content for each type of activity?
似乎无法设置邮件消息的主题行或收件人.我已经阅读了文档,他们认为使用使用 mailto: 协议的 NSURL 可能是可能的,但在我的测试中,这些 URL 只是被推送到消息正文中.实际上有没有办法设置主题行和可选的收件人?
There appears to be no way to set a subject line or recipient for Mail messages. I've read the docs, they make it sound like this might be possible with an NSURL that uses the mailto: protocol, but in my tests, those URLs just get shoved into the message body. Is there actually a way to set the subject line and optionally, the recipients?
如果我想解决这些缺点,并通过继承 UIActivity 来做我自己的自定义活动,我必须使用自定义图像/图标.因此,我无法使用 Apple 的官方图标来模拟邮件活动,例如实现我自己的自定义活动后端,实际上可以让我设置主题行、收件人、自定义正文等.我错了,有没有办法使用 Apple 的服务图标,但有机会自定义行为?(我看到的唯一回调是在活动完成后运行的回调,对吗?)
If I want to work around these shortcomings, and do my own custom activities by subclassing UIActivity, I have to use a custom image/icon. Therefore, I can't mimic the Mail activity with Apple's official icon, and e.g. implement my own custom activity backend that actually lets me set the subject line, recipients, custom body, etc. Am I wrong, is there a way to use Apple's service icons, but have a chance to customize the behavior? (The only callback I see is one that runs AFTER the activity has been completed, right?)
我希望我是错的!
推荐答案
您最好使用行为类似于 UIAcitvityController
的自定义组件,因为它非常有限,正如您所指出的.
You are better off using a custom component that behaves like UIAcitvityController
as it is quite limited, as you noted.
这是一个例子:https://github.com/hjnilsson/REActivityViewController,我只是分叉它来自 https://github.com/romaonthego/REActivityViewController 允许您设置电子邮件主题字段.
This is one example: https://github.com/hjnilsson/REActivityViewController , I just forked it from https://github.com/romaonthego/REActivityViewController to allow you to set the email subject field.
这篇关于我是不是不理解 UIActivityViewController,还是目前的实现很糟糕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!