我一直在尝试使用新的 UIActivityViewController 来替换我所有的 UIActionSheets 进行共享,但是我遇到了一个问题。
我有 5 个活动,消息、电子邮件、复制、Twitter 和 Facebook。我已经想出了如何让它们显示不同的文本,通过这个在自定义 UIActivityProvider 子类中:
- (id) activityViewController:(UIActivityViewController *)activityViewController
itemForActivityType:(NSString *)activityType
{
if ( [activityType isEqualToString:UIActivityTypePostToTwitter] )
return twitter;
if ( [activityType isEqualToString:UIActivityTypePostToFacebook] )
return facebook;
if ( [activityType isEqualToString:UIActivityTypeMessage] )
return urlScheme;
if ( [activityType isEqualToString:UIActivityTypeMail] )
return urlScheme;
if ( [activityType isEqualToString:UIActivityTypeCopyToPasteboard])
return urlScheme;
return nil;
}
这在我的视图控制器中:
ActivityProvider *aProvider = [[ActivityProvider alloc] init];
aProvider.facebook = facebook;
aProvider.twitter = twitter;
aProvider.urlScheme = URL;
NSArray *Items = @[aProvider, sharedURL];
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:Items applicationActivities:Nil];
activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll, UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:TRUE completion:nil];
但是,我只想在 Facebook 和 Twitter 共享表中显示 URL (sharedURL),而不是消息、电子邮件或副本。有什么办法可以做到这一点?