Is it possible to have a UITextField selected without a keyboard present?

Advertisement

Summary of my situation

My application uses a barcode scanner that acts as an external keyboard. While on a particular view, I want to have a hidden text field selected without having a keyboard present. Then I can ask the barcode scanner to send data to this text field.

I use an IPad Air 2.

What I have done so far

I have configured the InputView and InputAccessoryView text fields for vivid UIViews.

 _barcodeText.inputView = [[UIView alloc] initWithFrame:CGRectZero]; _barcodeText.inputAccessoryView = [[UIView alloc] initWithFrame:CGRectZero]; 

This works mostly, but it leaves this upper part of the keyboard:

I have tried to resolve this by removing UIRemoteKeyboardWindow in methods to delegate text fields, but this solution seems to be very inconsistent and could cause more problems in other parts of my application. The code I use to do this is:

 // LOOP THROUGH WINDOWS for(NSObject *window in [[UIApplication sharedApplication] windows]){ // GET CLASS NAME NSString *name = NSStringFromClass([window class]); // CHECK FOR KEYBOARD WINDOW if([name isEqualToString:@"UIRemoteKeyboardWindow"]){ // REMOVE KEYBOARD [(UIWindow*)window removeFromSuperview]; [(UIWindow*)window setHidden:true]; } } 

The answer

Unfortunately, you can not completely get rid of the keyboard. What I did was use the Sockets barcode scanner, linked here: https://www.socketmobile.com/home/?languageRedirect=true

They have an SDK that sends data via bluetooth and the keyboard is left alone to do whatever you want with it.