在 ios 中将图像复制到粘贴板
Image copying to pasteboard in ios
我有一个应用程序,我想在其中复制图像并将其粘贴到短信应用程序中。
我正在使用下面的代码。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"Heritage" ofType:@"png"];
NSData *data = [NSData dataWithContentsOfFile:filePath];
[pasteboard setData:data forPasteboardType:@"public.png"];
}
我在 google 上搜索后得到了这段代码,其中有很多代码,但不知何故 none 似乎对我有用。
当我 运行 应用程序并转到短信应用程序并按时,粘贴选项没有显示在那里。
Heritage.png 是我的应用程序包中的一张图片。
我哪里做错了?
请告诉我。
谢谢...
终于有了自己的解决方案。
我没有启用键盘扩展以允许完全访问。
刚刚忘记将 "RequestOpenAccess" 设置为 "YES"。
希望别人不要忘记检查这个小东西。
谢谢...
我有一个应用程序,我想在其中复制图像并将其粘贴到短信应用程序中。
我正在使用下面的代码。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"Heritage" ofType:@"png"];
NSData *data = [NSData dataWithContentsOfFile:filePath];
[pasteboard setData:data forPasteboardType:@"public.png"];
}
我在 google 上搜索后得到了这段代码,其中有很多代码,但不知何故 none 似乎对我有用。
当我 运行 应用程序并转到短信应用程序并按时,粘贴选项没有显示在那里。
Heritage.png 是我的应用程序包中的一张图片。
我哪里做错了?
请告诉我。
谢谢...
终于有了自己的解决方案。
我没有启用键盘扩展以允许完全访问。
刚刚忘记将 "RequestOpenAccess" 设置为 "YES"。
希望别人不要忘记检查这个小东西。
谢谢...