UIActivityViewController可选/针对不同ActivityTypes的不同内容

时间:2015-06-09 13:42:38

标签: ios objective-c share uiactivityviewcontroller

我必须将本机共享选项集成到我的项目中。

这是到目前为止的代码:

- (IBAction)shareButtonClicked:(id)sender
{

    NSString *text = @"This is the share text";
    NSString *url = [NSString stringWithFormat:@"http://share.me/"];
    UIImage *image = [UIImage imageNamed:@"icon"];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[text,url,image] applicationActivities:nil];

    [activityVC setValue:@"Share Subject" forKey:@"subject"];


    NSArray *excludeActivities = @[UIActivityTypeAirDrop,
                                   UIActivityTypePrint,
                                   UIActivityTypeAssignToContact,
                                   UIActivityTypeSaveToCameraRoll,
                                   UIActivityTypeAddToReadingList,
                                   UIActivityTypePostToFlickr,
                                   UIActivityTypePostToVimeo];

    activityVC.excludedActivityTypes = excludeActivities;

    [self presentViewController:activityVC animated:YES completion:nil];
}

它工作正常,但我确实有问题。我不想要ActivityType Message和Facebook Messenger中的图像。

这似乎很有用:http://www.albertopasca.it/whiletrue/2012/10/objective-c-custom-uiactivityviewcontroller-icons-text/

但我不希望我的活动有不同的文字。我只是想“停用”特定活动的图像。

是否有更简单的方法来完成工作而不是UIActivity的子类? 就像这里:iOS 6 - UIActivityViewController items

类似的东西:

if(userClickedActivity == UIActivityTypePostToMessage){
    self.setimage = nil;
}

到目前为止,谢谢!

0 个答案:

没有答案