问题描述
最近 iOS 更新了 iOS 10 &对开发人员有一些更改,其中一项更改是现在我们无法检查 允许完全访问 我们以前的方式如下所示
Recently iOS has an update of iOS 10 & there are certain changes for developers one of the change is now we can't check allow full access the way we did previously is given below
-(BOOL)isOpenAccessGranted{ return [UIPasteboard generalPasteboard]; }
我搜索了最新的UIPasteboard 开发者指南,但找不到解决它.有没有人对此有适当的解决方案.
I searched the latest Developer Guide for UIPasteboard, but was unable to solve it. Did any one has a proper solution for this.
推荐答案
iOS11及以上很简单.
iOS11 and above is easy.
iOS10 解决方案:勾选所有可复制类型,如果其中一个可用,则您有完全访问权限,否则没有.
iOS10 Solution: Check all the copy-able types, if one of them is available, you have full access otherwise not.
-- 斯威夫特 4.2--
-- Swift 4.2--
override var hasFullAccess: Bool { if #available(iOS 11.0, *){ return super.hasFullAccess// super is UIInputViewController. } 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) } }