ios - 如何提高登录验证的速度?
<p><p>我正在努力添加 LocalAuthentication 框架,以允许用户在类似设备上使用指纹进行身份验证。一切正常,但是当用户通过指纹进行身份验证时,需要 10-15 秒才能执行正确的 segue,这是典型的,还是我验证用户的方式有问题?
代码:</p>
<pre><code>-(void)viewDidLoad { ; ];
UIBarButtonItem *anotherButton = [ initWithTitle:@"Register" style:UIBarButtonItemStylePlain target:self action:@selector(onRegisterTapped)]; self.navigationItem.rightBarButtonItem = anotherButton;
LAContext *context = [ init];
NSError *error = nil; if () { [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Login?" reply:BOOL success, NSError *error {
if (error) {
}
if (success) {
;
} else {
}
}];
} else {
UIAlertView *alert = [ initWithTitle:@"Error"
message:@"Your device cannot authenticate using TouchID."
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
;
} }
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>因此,执行 segue 可能与主要应在主线程上执行的 View 操作有关。我不太确定,但很可能 <code>evaluatePolicy</code> 方法是在后台线程上执行的。如果是这种情况,您可能希望将 <code>performSegue</code> 扔到主线程上。 </p>
<p>为此,请使用:</p>
<pre><code>dispatch_async(dispatch_get_main_queue(), ^{
;
});
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何提高登录验证的速度?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/27278338/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/27278338/
</a>
</p>
页:
[1]