如何在UIActivityViewController中向Activity活动栏添加ActivityItem? [英] How can I add a ActivityItem to upper activity bar in UIActivityViewController?

查看:106
本文介绍了如何在UIActivityViewController中向Activity活动栏添加ActivityItem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将自己的WhatsApp ActivityItem 添加到 UIActivityViewController ,但它总是添加到较低的非彩色活动栏,但我喜欢将它添加到上面的栏中,带有彩色项目。

I like to add my own WhatsApp ActivityItem to the UIActivityViewController, but it is always added to the lower non colored activity bar, but I like to add it to the upper bar, the one with the colored items.

这就是我使用的代码:

WhatsApp *whatsApp = [[WhatsApp alloc] init];
            UIActivityViewController* activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[image, text] applicationActivities:@[whatsApp]];

赞。

推荐答案

在自定义 UIActivity 子类你必须简单地覆盖一个方法:

In your custom UIActivity subclass you have to simply override one method:

+ (UIActivityCategory)activityCategory
{
   return UIActivityCategoryShare;
}

有可能的类别:行动和分享。

重要的是,这是方法,而不是实例。此外,它是iOS 7特定的 - 所有行动活动都放在底线(如果有的话),然后在共享活动之上,然后在AirDrop之上。因此,如果您想要摆脱底线,只需排除所有行动活动。如果您想在共享/操作行中添加内容 - 覆盖 activityCategory 。默认为UIActivityCategoryShare;

There are to possible categories: action and share.
It's important, this is class method, not instance. Also, it's iOS 7 specific - all action activities are placed in bottom line (if any), then above the share activities and then above AirDrop. So, if you want to get rid of bottom line for example, simply exclude all action activities. If you want to put something in share/action line - override activityCategory. default is UIActivityCategoryShare;

这篇关于如何在UIActivityViewController中向Activity活动栏添加ActivityItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆