gpt4 book ai didi

iphone - 将视频复制到 uipasteboard

转载 作者:可可西里 更新时间:2023-11-01 03:09:37 27 4
gpt4 key购买 nike

我已成功使用以下代码将图像复制或添加到粘贴板:

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com