问题
I have successfully able to copy or add the image to pasteboard by using following code:
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];
But the app which I am making is based on both images and videos so that user will be able to send image/video via imessage or messagecomposer. But as I have convert the image into data and added into pasteboard. It is working succesfully and sending through imessage. But I also need to send video via imessage. If anyone has any idea about this please provide me some suggestion or solution.
I would be very thankful for the help.
回答1:
I have also faced the same issue in sending audio file from SMS. But sending video and audio from SMS is not possible with current SDK. You can do this by uploading that video to server and then send that uploaded URL.
How to programmatically send voicemail message on the iPhone?
回答2:
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://pathto.mp4"]];
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
[pasteBoard setData:data forPasteboardType:@"public.mpeg-4"];
@"public.mpeg-4"
from http://www.escape.gr/manuals/qdrop/UTI.html
来源:https://stackoverflow.com/questions/13989625/copy-video-to-uipasteboard