所以我一直在搜索stackoverflow,我无法找到答案.当用户点击"输入密码"时,如何允许用户访问内置的Apple密码屏幕?请单击下面提供的链接以查看此问题的图像说明.感谢您的帮助,请在Swift中写下来!
http://i.stack.imgur.com/id9E3.jpg
这可以通过iOS 9来完成,它暴露了一种新LAPolicy
类型,即在调用时evaluatePolicy
,传入DeviceOwnerAuthentication
和不 传入DeviceOwnerAuthenticationWithBiometrics
.
这里有一些快速:
import LocalAuthentication function authenticateUser() { let context = LAContext() context.evaluatePolicy(LAPolicy.DeviceOwnerAuthentication, localizedReason: "Please authenticate to proceed.") { [weak self] (success, error) in guard success else { dispatch_async(dispatch_get_main_queue()) { // show something here to block the user from continuing } return } dispatch_async(dispatch_get_main_queue()) { // do something here to continue loading your app, e.g. call a delegate method } } }
现在,当用户用错误的手指点击主页按钮时,警告框将显示"输入密码"选项:
点击Enter Passcode
将显示两个提示之一,具体取决于用户是否设置了数字或字母数字密码:
数字密码:
字母数字密码: