问题描述
最近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];
}
我搜索了最新的,但无法解决。是否有任何人有适当的解决方案。
I searched the latest Developer Guide for UIPasteboard, but was unable to solve it. Did any one has a proper solution for this.
推荐答案
iOS10解决方案:检查所有可复制的类型,如果其中之一可用,你有完全访问权限,否则没有。
iOS10 Solution: Check all the copy-able types, if one of them is available, you have got the full access otherwise not.
PS:新手机和iOS更新案例修复后。
P.S: New phone and after iOS update cases are fixed.
- Swift 2.3 -
-- Swift 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 -
-- 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)
}
}
这篇关于允许完全访问权限检查键盘iOS10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!