Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force keyboard to show up via button (iOS)

I have an UITextView and I don't want check editable option, how can call keyboard via a button? This code doesn't work for me!

-(IBAction) yourButtonClick
{
    [myTextView becomeFirstResponder];
    [self.view addSubview:myTextView]; 
}
like image 742
iOS.Lover Avatar asked May 01 '10 15:05

iOS.Lover


People also ask

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 fix my iPhone keyboard not appearing?

Simply, restart your device and you might be surprised to see the keyboard back and working on your iPhone or iPad. Go to Settings > General > scroll down and tap on Shut Down. On the next screen, use the Slider to Shut Down iPhone. Wait for 30 seconds and Restart iPhone.

How do I get the floating keyboard on my iPhone?

Open any app that uses the keyboard, such as the Notes app. Tap and hold the keyboard icon in the bottom right corner of the keyboard. A menu will appear. Keep holding your finger on the screen and drag your finger to select the Floating keyboard option.

Why won't my keyboard pop up on my iPad?

As is often the case with computers, it's possible that some sort of temporary software glitch is keeping the keyboard from appearing on screen. Restarting your iPad — turning it off and then back on again — can resolve most of these kinds of problems. Restart it and check the onscreen keyboard again.


1 Answers

From the iPhone Application Programming Guide

However, you can programmatically display the keyboard for an editable text view by calling that view’s becomeFirstResponder method. Calling this method makes the target view the first responder and begins the editing process just as if the user had tapped on the view.

So to show the keyboard programmatically,

[textView becomeFirstResponder];

However, the keyboard will never show if the textView is not editable.

The purpose of showing the keyboard is to allow editing. I assume you just don't want the keyboard to appear when the user taps the text view. In this case, you can enable editable programmatically when the button is tapped.

-(IBAction) yourButtonClick
{
     myText.editable = YES;
     [myText becomeFirstResponder];

}

Then in the UITextViewDelegate, disable editable when the user finishes editing.

- (void)textViewDidEndEditing:(UITextView *)textView {
  textView.editable = NO;
}
like image 85
Arrix Avatar answered Sep 18 '22 16:09

Arrix