UIPasteboard之pasteboardTypes

最近在做类似淘宝口令码的需求,发现个有关UIPasteboard的疑问。先看下面这个方法

#Summary

Returns whether the pasteboard holds data of the specified representation type.
# Discussion

This method works on the first item in the pasteboard. If there are other items, it ignores them. You can use this method when enabling or disabling the Paste menu command.

Starting in iOS 10, you can directly check which data types are present on a pasteboard by using the convenience methods described in [Checking for Data Types on a Pasteboard](apple-reference-documentation://hcPbJVw0Dk).

- (BOOL)containsPasteboardTypes:(NSArray<NSString *> *)pasteboardTypes;
 

Checking for Data Types on a Pasteboard

image.png

上面的文档意思是containsPasteboardTypes用来判断pasteboard是否持有的数据类型,自iOS10以后可以使用hasImages、hasStrings等方法来替代。

然而问题是

当剪切板复制了一张图片,通过hasStrings判断结果为true,string内容为图片地址,这里就不举例说明。
此时想判断剪切板内容依然需要通过containsPasteboardTypes来判断。pasteboardTypes如Uniform Type Identifiers OverviewCoreServices/UTCoreTypes.h所示.

谢谢~

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容