我想要做的是将我的应用程序中的一些图像粘贴到 SMS 中。
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *imagefile = [[NSBundle mainBundle]
pathForResource:@"imagename"]
ofType:@"png"];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagefile];
if (fileExists){
UIImage *ui = [[UIImage alloc] initWithContentsOfFile:imagefile];
pasteboard.image = ui;
[ui release];
}
在调试模式下,我发现图像确实存在,并且它确实进入了粘贴板(我检查了它我引入了一个带有粘贴板图像的图像视图,这是必要的)。
保存到剪贴板后,我打电话
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];
它确实弹出,但是当我点击那里的“文本字段”时,没有显示粘贴按钮。有人可以指出我的错误吗? 或者这样做有意义吗?我的意思是,是否可以通过默认 iPhone 消息应用程序发送图像?