1

I'm trying to integrate an external scanner with HID interface, so I use a UITextView to capture the scanner data (A HID device is like a keyboard), and the screen has several nested views, I show a table view with a master-detail in a subview.

I use a UISwitch (with label "Use external scanner") to force the focus on my UITextView, If I enable the switch the scanner is correctly read and It works Ok.

The hierarchy It's similar to:

  • Scanner view (contains the UITextView with the UISwitch and some other fields)
    • Table view with a list (a subview of the scanner view)
    • Detailed view

My application use an story board, my problem is that after I force the focus on the UITextView, if I touch on the table view and a detailed view appears, the focus seems lost and the scanner is no longer read. I've checked with a UITimer that runs every 2 seconds that the UITextView is still the first responder (I use this answer to find the first responder: https://stackoverflow.com/a/14135456/661140), but for some reason is not responding.

I've tried to detect when the focus is lost using - (void)textViewDidEndEditing:(UITextView *)textView but It doesn't work

- (void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView == _hiddenTextExternalScannerTextView)
    {
        NSLog(@"Text view has lost the focus in textFieldDidEndEditing");
    }
}

Can anyone tell me why the UITextView is not responding to keyboard events ? Is there any way to detect when the field is no longer responding ?

I did the same test without the HID device, only the internal keyboard, and when I browse out of the field, the keyboard is dismissed, but the field is still detected like the first responder.

Community
  • 1
  • 1
Roberto
  • 8,586
  • 3
  • 42
  • 53
  • in storyboard select your tableView and in the attributes inspector, there is a field about keyboard, be sure than you have selected do not dismiss – Onik IV Dec 15 '14 at 15:12
  • @OnikIV, when I use the HID device the keyboard doesn't appear so It's no dismissed, It's similar to a bluetooth keyboard. – Roberto Dec 15 '14 at 15:30

0 Answers0