views:

297

answers:

1

Hi , 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
{
     [myText becomeFirstResponder];
[self.view addSubview:myTex]; 

}

thank you .

+2  A: 

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;
}
Arrix
ahaaaaa thank you very much i add this code textPad.editable = YES;and works great
Mc.Lover