我已成功使用以下代码将图像复制或添加到粘贴板:
if (ver_float < 6.0)
{
UIPasteboard *pasteboard;
pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath =pathToImage;
[pasteboard setImage:[UIImage imageWithContentsOfFile:filePath]];
}
else
{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath =pathToImage;
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
[pasteboard setData:videoData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];
}
NSURL *urlstr = [NSURL URLWithString:@"sms:"];
[[UIApplication sharedApplication] openURL:urlstr];
但我正在制作的应用程序是基于图像和视频的,因此用户将能够通过 imessage 或 messagecomposer 发送图像/视频。但是因为我已经将图像转换为数据并添加到粘贴板中。它正在成功工作并通过 imessage 发送。但我还需要通过 imessage 发送视频。如果有人对此有任何想法,请给我一些建议或解决方案。
非常感谢您的帮助。
最佳答案
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://pathto.mp4"]];
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
[pasteBoard setData:data forPasteboardType:@"public.mpeg-4"];
@"public.mpeg-4"
来自 http://www.escape.gr/manuals/qdrop/UTI.html
关于iphone - 将视频复制到 uipasteboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13989625/