允许完全访问权限检查键盘iOS10

最近iOS有iOS 10和更新版本开发人员有一些变化,现在我们无法检查允许完全访问,我们之前的方式如下所示
-(BOOL)isOpenAccessGranted{
   return [UIPasteboard generalPasteboard];
 }

搜索了最新的Developer Guide for UIPasteboard,但无法解决.有没有人有一个适当的解决方案.

解决方法

iOS10解决方案:检查所有可复制的类型,如果其中一个可用,则您将获得完全访问权限.

P.S:新手机和iOS更新案例修复后.

– 斯威夫特2.3–

static func isFullAccessGranted() -> Bool
{
    if #available(iOSApplicationExtension 10.0,*)
    {            
        if UIPasteboard.generalPasteboard().hasstrings
        {
            return  true
        }
        else if UIPasteboard.generalPasteboard().hasURLs
        {
            return true
        }
        else if UIPasteboard.generalPasteboard().hasColors
        {
            return true
        }
        else if UIPasteboard.generalPasteboard().hasImages
        {
            return true
        }
        else // In case the pasteboard is blank
        {
            UIPasteboard.generalPasteboard().string = ""

            if UIPasteboard.generalPasteboard().hasstrings
            {
                return  true
            }else
            {
                return  false
            }
        }
    } else {
        // before iOS10
        if UIPasteboard.generalPasteboard().isKindOfClass( UIPasteboard)
        {
            return true
        }else
        {
            return false
        }
    }
}

– Swift 3.0–

static func isFullAccessGranted() -> Bool
{
    if #available(iOSApplicationExtension 10.0,*)
    {            
        if UIPasteboard.general.hasstrings
        {
            return  true
        }
        else if UIPasteboard.general.hasURLs
        {
            return true
        }
        else if UIPasteboard.general.hasColors
        {
            return true
        }
        else if UIPasteboard.general.hasImages
        {
            return true
        }
        else  // In case the pasteboard is blank
        {
            UIPasteboard.general.string = ""

            if UIPasteboard.general.hasstrings
            {
                return  true
            }else
            {
                return  false
            }
        }
    } else {
        // before iOS10
        return UIPasteboard.general.isKind(of: UIPasteboard.self)
    }
}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...