Example of how to customize UIActivityViewController share menu?

大城市里の小女人 提交于 2019-11-29 12:47:41

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/12719931/example-of-how-to-customize-uiactivityviewcontroller-share-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!