UIActivityViewController - 项目的顺序 [英] UIActivityViewController - order of items

查看:31
本文介绍了UIActivityViewController - 项目的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列想要分享的项目.如何强制执行特定命令?例如:

I Have an array of items I want to share. How can I force to have a specific order? For example:

NSArray *itemsToShare = @[text, image, image, audio]

数组中项目的顺序不适用于共享应用中的顺序.

The order of the items in the array does not work for the order in the shared app.

推荐答案

您不能强制共享项的特定顺序,无论如何共享项都不是问题,这只是告诉委托基于哪些 UIActivity 应用程序填充关闭您提供的一系列信息.您尝试重新排序 UIActivityViewController 中支持的应用程序.您可以使用 excludedActivityTypes 排除某些内置项目,如相机胶卷、Facebook 等,以省略与您的共享项目无关的某些共享点.
目前最好的选择是将 UIActivityViewController 子类化,您可以在其中为 UIActivityViewController 创建自定义图标等,但这将不允许您重新排序支持的应用程序.但是,您有更多的选项可以通过子类化进行自定义:canPerformWithActivityItems: prepareWithActivityItems: 等等.你可以试试这个,看看你是否可以自定义子类中显示的活动,例如子类:

You can't force a specific order of shared items, the shared items isn't the issue anyways, that's just telling the delegate what UIActivity applications to populated based off the array of information you provided. Your trying to reorder the applications supported in the UIActivityViewController. You can exclude certain items that are built in like camera roll, Facebook etc using excludedActivityTypes to omit certain share points from populating that aren't relevant to your shared item.
Your best bet at this moment, is to either subclass UIActivityViewController where you can create custom icons etc for your UIActivityViewController, but this won't allow you to reorder the applications supported. However you have a lot more options for customizing by subclassing: canPerformWithActivityItems: prepareWithActivityItems: etc. You might be able to play around with this and see if you can customize the activities displayed in a subclass an example to subclass :

- (UIActivityViewController *)subclassedActivityViewController {
CustomActivity *customActivity = [[CustomActivity alloc] init];
FacebookActivity *facebookActivity = [[FacebookActivity alloc] init];
MessageActivity *messageActivity = [[MessageActivity alloc] init];
MailActivity *mailActivity = [[MailActivity alloc] init];

NSArray *applicationActivities = @[customActivity, facebookActivity, mailActivity, messageActivity];
NSArray *activitiesItems = @[@"A string to be used for customActivity", @"A string to be used for FacebookActivity", @"A string to be used for MessageActivity" etc];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activitiesItems applicationActivities:applicationActivities];

// Removed activities you don't want displayed
activityVC.excludedActivityTypes = [[NSArray alloc] initWithObjects:
                                                 UIActivityTypeCopyToPasteboard,
                                                 UIActivityTypePostToWeibo,
                                                 UIActivityTypePostToFacebook,
                                                 UIActivityTypeSaveToCameraRoll,
                                                 nil];

return activityVC;
}

但是,如果这不能解决您的问题,那么您将不得不创建自己的 UIActivityViewController,直到他们实现此功能.

However if this doesn't circumvent your issue then you will have to create your own UIActivityViewController until they implement this feature.

这篇关于UIActivityViewController - 项目的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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