如何将 ActivityItem 添加到 UIActivityViewController 中的上部活动栏? [英] How can I add a ActivityItem to upper activity bar in UIActivityViewController?

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

问题描述

我喜欢将自己的 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;
}

有可能的类别:操作和分享.
重要的是,这是 class 方法,而不是实例.此外,它是特定于 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;

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

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