1

I got a security controller that trigger Touch ID when app become active. If user cancel the Touch ID box, a keyboard is shown to enter a digital code. But my keyboard is loaded (inputAccessoryView is drawn at good position) but invisible. I need to background and foreground the app to keyboard to be visible.

I tried this solution that doesn't work : 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];
    });
}
Community
  • 1
  • 1
Ludovic
  • 1,992
  • 1
  • 21
  • 44

1 Answers1

3

As a temporary fix, call becomeFirstResponder with a delay (by using dispatch_after) but still on the main queue.

My guess for the issue is, the TouchID view is on another window than the app's normal window. When user cancels the TouchID auth, the TouchID window is still the key window, thus calling your UITextField on the below window has some issue popping up the keyboard. But as I've said, this is just a guess.

Update with code:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void){
    // Pop the keyboard
});
James Chen
  • 10,794
  • 1
  • 41
  • 38
  • it's works... for now, I will try to debug more deeply! Thanks for the hotfix :) – Ludovic Dec 20 '16 at 11:04
  • It is still not working in my iPhone 7 Plus, `dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.33 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ [fakeField becomeFirstResponder]; });` after Touch ID passcode cancel event. – Max Jun 06 '17 at 10:38