在IOS中从pdf或uiwebview复制图像?

时间:2012-07-22 10:44:42

标签: ios image uiimageview uipasteboard

如何在用户点击复制后从UIPasteboard获取图像实际上我可以从UIPasteboard获取Nsdata但我认为需要将特定的编码分配给uiimageview我该怎么做?谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

NSData *data = // however you obtain the data
UIImage *image = [[UIImage alloc] initWithData:data];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imageView];

更好:

UIImage *image = [[UIPasteboard generalPasteboard] image];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imageView];