我习惯使用UIDocumentInteractionController
和UIActivityViewController
与特殊UTI
分享数据。
但是,当其他应用使用Share Extension
时,共享界面弹出窗口可能会有选项,例如copy tp xxx
和import to xxx
。
如何禁用这些选项,或者是否有任何其他方式可以将数据共享到我可以控制的指定应用程序。
// ======= 我的代码是这样的:
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:@[itemUrl] applicationActivities:nil];
activity.excludedActivityTypes = @[UIActivityTypePostToFacebook, UIActivityTypePostToFacebook,UIActivityTypePostToWeibo,
UIActivityTypeMessage, UIActivityTypeMail, UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr, UIActivityTypePostToFlickr, UIActivityTypePostToFlickr,
UIActivityTypeAirDrop];
[self presentViewController:activity animated:YES completion:NULL];
答案 0 :(得分:0)
创建一个数组并添加不想向用户显示的类型,例如
NSArray *excludeActivities = @[UIActivityTypeAirDrop,
UIActivityTypePrint,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo,
UIActivityTypeCopyToPasteboard];
Create a instance of UIActivityViewController
And set following propery
activityViewController.excludedActivityTypes = excludeActivities
答案 1 :(得分:0)
我发现如果您分享为NSURL
,您将获得copy to xxx
或import to xxx
,但如果您分享为UIImage
,则无法获得该信息。
将显示import to xxx
avc = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObjects:fileURL, nil] applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];
不会显示
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:fileURL]];
avc = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObjects:image, nil] applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];