如何自定义UIActivityViewController共享菜单的示例? [英] Example of how to customize UIActivityViewController share menu?
问题描述
是否有一个如何使用我自己的图标和 IBAction
自定义 UIActivityViewController
共享菜单的示例?
我见过这个......
- (id)initWithActivityItems :( NSArray *)activityItems applicationActivities:(NSArray *)applicationActivities;
但我还没有让它工作。
您首先需要继承 UIActivity
。
然后你需要覆盖某些方法,包括 activityImage
来设置图标和 performActivity
用于执行操作(在您的问题中称为IBAction)。
如果不是静默执行操作,首先需要进一步用户交互和自定义活动的信息(例如,像标准UIActivity的Twitter帖子),你应该覆盖 activityViewController
而不是 performActivity
。
在你有 UIActivity
的子类后(例如, MyActivity
),你应该创建一个 MyActivity
的实例,并使它成为你传递给的 applicationActivities
数组的一个元素 initWithActivityItems:applicationActivities:
。
看看 UIActivity的文档,确切地说明了在子类化和图标要求时需要覆盖的内容。 / p>
希望这会有所帮助。
Is there an example of how to customize UIActivityViewController
share menu with my own icon and IBAction
?
I have seen this...
- (id)initWithActivityItems:(NSArray *)activityItems applicationActivities:(NSArray *)applicationActivities;
but I have not gotten it to work yet.
You first need to subclass 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).
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
.
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:
.
Have a look at the documentation for UIActivity for exactly what you need to override when subclassing and for icon requirements.
Hope this helps a little.
这篇关于如何自定义UIActivityViewController共享菜单的示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!