xcode 如何自定义 UIActivityViewController 共享菜单的示例?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12719931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Example of how to customize UIActivityViewController share menu?
提问by OscarTheGrouch
Is there an example of how to customize UIActivityViewController
share menu with my own icon and IBAction
?
是否有一个示例说明如何UIActivityViewController
使用我自己的图标和自定义共享菜单IBAction
?
I have seen this...
我见过这个...
- (id)initWithActivityItems:(NSArray *)activityItems applicationActivities:(NSArray *)applicationActivities;
but I have not gotten it to work yet.
但我还没有让它工作。
回答by Spiros
You first need to subclass UIActivity
.
您首先需要将UIActivity
.
Then you need to override certain methods, including activityImage
for setting the icon and performActivity
for performing the action (what you call "IBAction" in your question).
然后您需要覆盖某些方法,包括activityImage
设置图标和performActivity
执行操作(您在问题中称为“IBAction”)。
If instead of performing the action silently, you first need further user interaction and info for your custom activity (e.g., like the Twitter post for the standard UIActivity), you should override activityViewController
rather than performActivity
.
如果不是静默执行操作,您首先需要自定义活动的进一步用户交互和信息(例如,标准 UIActivity 的 Twitter 帖子),您应该覆盖activityViewController
而不是performActivity
。
After you have subclassed UIActivity
(as, e.g, MyActivity
), you should create an instance of MyActivity
and make it an element of the applicationActivities
array that you pass to initWithActivityItems:applicationActivities:
.
在子类化UIActivity
(例如,MyActivity
)之后,您应该创建 的实例MyActivity
并将其applicationActivities
设为您传递给的数组的元素initWithActivityItems:applicationActivities:
。
Have a look at the documentation for UIActivityfor exactly what you need to override when subclassing and for icon requirements.
查看UIActivity 的文档,了解在子类化和图标要求时需要覆盖的内容。
Hope this helps a little.
希望这有所帮助。