ios - TouchID 后应用程序变为事件状态时键盘不可见

标签 ios uitextfield ios10 uikeyboard

我有一个安全 Controller ,当应用程序激活时触发 Touch ID。如果用户取消 Touch ID 框,则会显示一个键盘以输入数字代码。但是我的键盘已加载(inputAccessoryView 绘制在良好的位置)但不可见。我需要将应用程序的背景和前景设置为键盘可见。

我尝试了这个不起作用的解决方案:Super slow lag/delay on initial keyboard animation of UITextField

if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
    [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:myLocalizedReasonString
    reply:^(BOOL success, NSError *error) {
        if (success) {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSLog(@"User authenticated successfully, take appropriate action");
            });
        } else {
            NSLog(@"User did not authenticate successfully, look at error and take appropriate action");

            dispatch_async(dispatch_get_main_queue(), ^(void){
                [self._fieldSecurity becomeFirstResponder];
            });
        }
    }];
} else {
    NSLog(@"Could not evaluate policy; look at authError and present an appropriate message to user");
    dispatch_async(dispatch_get_main_queue(), ^{
        [self._fieldSecurity becomeFirstResponder];
    });
}

最佳答案

作为临时修复,请调用 becomeFirstResponder有延迟(通过使用 dispatch_after )但仍在主队列中。

我对这个问题的猜测是,TouchID View 位于应用程序正常窗口之外的另一个窗口上。当用户取消 TouchID 身份验证时,TouchID 窗口仍然是关键窗口,因此调用您的 UITextField在下面的窗口中有一些问题弹出键盘。但正如我所说,这只是一个猜测。

用代码更新:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void){
    // Pop the keyboard
});

关于ios - TouchID 后应用程序变为事件状态时键盘不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41014184/

相关文章:

ios - 从 UIActivityViewController 禁用 Messenger

ios - iOS10 中的动画导航栏 barTintColor 更改不起作用

ios - 如何让音量键对 Audioplyer Sound 不显示效果

ios - 触摸 UITextField 以外的任何地方时如何关闭键盘( swift )?

ios - UITextField shouldChangeCharactersInRange

ios - 打字时缩小 BackSpace 上的 UITextField 范围

swift - Firebase 通知和 Firebase 数据库功能不能在我的应用程序中同时工作

UINavigationController 的 setViewControllers 在 IOS10 中添加后退按钮

ios - 链接器错误断言失败 : (atom->fixupCount() == 1)

ios - PhoneGap/Cordova 应用程序是否在 HTTP 下运行?