如何将API和获取的数据传递给UIActivityViewCollector

时间:2016-06-13 05:29:59

标签: ios uiactivityviewcontroller

我正在使用表格视图,我正在使用它来显示我从核心数据中获取的剪辑。现在我有一个剪辑路径的API,它将连接到服务器剪辑我想用该API传递剪辑ID并传递从核心数据获取的剪辑名称。我尝试了以下的东西使其工作,但给我错误。我想我做错了。我该怎么做。

       //here is my code but it is giving me error. Can't pass it this way.

   NSArray * activityItems = @[[NSURL URLWithString:@"http://example.com/view-videos.html?task=clip.details&id=%@",_fetchid]];  // this is giving me error and here i also want to send selected clip name with this API


UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:videoToShare applicationActivities:nil];

activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook,UIActivityTypePostToTwitter,UIActivityTypePostToWeibo,UIActivityTypeCopyToPasteboard,UIActivityTypeMessage];

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


   }

1 个答案:

答案 0 :(得分:1)

尝试这样的事情。您正在传递一些其他对象而不是activityItems。

NSString *urlString = [NSString stringWithFormat:@"http://example.com/view-videos.html?task=clip.details&id=%@",fetchid];
NSArray * activityItems = @[[NSURL URLWithString:urlString]];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook,UIActivityTypePostToTwitter,UIActivityTypePostToWeibo,UIActivityTypeCopyToPasteboard,UIActivityTypeMessage];
[self presentViewController:activityVC animated:YES completion:nil];

如果您想分享某些视频,请在activityItems数组对象中添加该视频

希望这会对你有所帮助。