Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show iPhone soft keyboard even though a hardware keyboard is connected

Tags:

My iPad app uses an external "device" that acts as a hardware keyboard. But, at some point in the settings, I need to input text and I can't use the "device" ("device" is not a keyboard). So, is there any way to force pop the soft keyboard even thought I have a hardware keyboard connected?

like image 871
tagyro Avatar asked Jul 24 '10 17:07

tagyro


People also ask

How do you bring up the virtual keyboard on IOS when a Bluetooth keyboard is connected?

Go to Settings > Accessibility > Keyboards > Full Keyboard Access (turn this on). You will be able to control your device with the keyboard. When you are typing in a window, press control to bring up the keyboard options.

How do I force my iPhone keyboard to appear?

Go to Settings > Accessibility > Keyboards, tap Full Keyboard Access, then turn on Full Keyboard Access.

How do I hide the onscreen keyboard when using Magic Keyboard on iPad?

When you're in an editing window, tap the Down Arrow key on your Magic Keyboard. Next, touch and hold the downward-facing chevron in the bottom-right corner of the screen until the onscreen keyboard appears. To hide the virtual keyboard again, tap the key in the bottom-right corner of the screen.

Does iPhone have an onscreen keyboard?

In apps on iPhone, you can use the onscreen keyboard to enter and edit text. You can also use Magic Keyboard and Dictation to enter text.


2 Answers

Yes. We've done this in a few of our apps for when the user has a Bluetooth scanner "keyboard" paired with the device. What you can do is make sure your textField has an inputAccessoryView and then force the frame of the inputAccessoryView yourself. This will cause the keyboard to display on screen.

We added the following two functions to our AppDelegate. The 'inputAccessoryView' variable is a UIView* we have declared in our app delegate:

//This function responds to all textFieldBegan editing // we need to add an accessory view and use that to force the keyboards frame // this way the keyboard appears when the scanner is attached -(void) textFieldBegan: (NSNotification *) theNotification {     UITextField *theTextField = [theNotification object];     //  NSLog(@"textFieldBegan: %@", theTextField);      if (!inputAccessoryView) {         inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, navigationController.view.frame.size.width, 1)];     }      theTextField.inputAccessoryView = inputAccessoryView;      [self performSelector:@selector(forceKeyboard) withObject:nil afterDelay:0]; }  //Change the inputAccessoryView frame - this is correct for portrait, use a different // frame for landscape -(void) forceKeyboard {     inputAccessoryView.superview.frame = CGRectMake(0, 759, 768, 265); } 

Then in our applicationDidFinishLaunching we added this notification observer so we would get an event anytime a text field began editing

    //Setup the textFieldNotifications     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldBegan:) name:UITextFieldTextDidBeginEditingNotification object:nil]; 

Hope that helps!

like image 129
Brian Robbins Avatar answered Sep 21 '22 02:09

Brian Robbins


There’s no way to do this with the current SDK. Please let Apple know via the Bug Reporter.

like image 37
Ben Stiglitz Avatar answered Sep 21 '22 02:09

Ben Stiglitz