最近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) } }