且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在UIActivityViewController中向Activity活动栏添加ActivityItem?

更新时间:2023-09-21 21:04:04

在自定义 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;