1、在使用系统分享时,如果想不显示某些分享方式,可以用黑名单的方式实现
比如不想显示Twitter和Facebook分享方式:
UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:@[image] applicationActivities:nil];
vc.excludedActivityTypes = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook];
[self presentViewController:vc animated:YES completion:nil];
2、但如果想只显示某些分享方式时,系统则没有提供api
比如只显示Twitter和Facebook分享方式
效果图:
使用方式:
CustomActivityViewController *vc = [[CustomActivityViewController alloc] initWithActivityItems:@[image] applicationActivities:nil];
vc.whiteList = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook];
[self presentViewController:vc animated:YES completion:nil];
实现方式:
@interface CustomActivityViewController : UIActivityViewController
@property (nonatomic, strong) NSArray *whiteList;
@end
@implementation CustomActivityViewController
- (NSArray *)includedActivityTypes {
return self.whiteList;
}
@end