美文网首页
UIPasteboard之pasteboardTypes

UIPasteboard之pasteboardTypes

作者: Luffy_Fit | 来源:发表于2019-11-26 23:15 被阅读0次

    最近在做类似淘宝口令码的需求,发现个有关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所示.

    谢谢~

    相关文章

      网友评论

          本文标题:UIPasteboard之pasteboardTypes

          本文链接:https://www.haomeiwen.com/subject/xphuwctx.html