ios复制到剪贴板

 UIPasteboard 这个就是剪贴板

 UIPasteboard * pastboard = [UIPasteboard generalPasteboard];

        pastboard.string = self.scanResult;

        

        [LCAlert toastShow:@"扫描结果已复制到剪贴板"];

 

常用方法:

/*通过名称获取粘贴板并且移除*/
+ (void)removePasteboardWithName:(NSString *)pasteboardName; 
/*从粘贴板中获取数据,pasteboardType是自定义的,说明app可以处理哪种类型的数据*/ - (nullable NSData *)dataForPasteboardType:(NSString *)pasteboardType;
/*data类型的数据放在粘贴板中,pasteboardType同上*/ - (void)setData:(NSData *)data forPasteboardType:(NSString *)pasteboardType;
/*从粘贴板中取出data*/ - (nullable NSData *)dataForPasteboardType:(NSString *)pasteboardType;
posted @ 2017-01-16 16:42  super1250  阅读(9872)  评论(0编辑  收藏  举报