最近在做類似淘寶口令碼的需求迫皱,發(fā)現個有關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 Overview咐扭、CoreServices/UTCoreTypes.h
所示.
謝謝~