将图像从URL保存到剪贴板

时间:2012-03-15 00:01:26

标签: iphone objective-c uipasteboard

我正在尝试将图像从URL保存到剪贴板。我尝试使用:

NSURL *url = [NSURL URLWithString:fromURL];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:url];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setData:imageData forPasteboardType:@"kUTTypeJPEG"]; //is kUTTypeJPEG even the right type?

但它不起作用。它不会发出警告,错误或其他任何内容。

1 个答案:

答案 0 :(得分:1)

试试这个,

将图像保存到剪贴板:

[UIPasteboard generalPasteboard] .image = someImage;

要从剪贴板再次获取图像:

UIImage * someImage = [UIPasteboard generalPasteboard] .image;