how can i edit the app extension custom keyboard,when use UIButton - ios

I want to edit my customKeyboard when I tap the UIButton that in my custom keyboard.
I have already add a UIButton in the keyboard,and the code like this:
- (IBAction)resignKeyboardButtonDidTouch:(id)sender {
[self.view endEditing:YES]; // it doesn’t work
}

You can resign keyboard for specific textField like,
[yourTextfield resignFirstResponder];
So, try this. You can set same tag to your button and textfield to identify particular textfield.

Related

Set text inputed from keypad on UILabel on UIButton click

i want to write the text to UILabel which is inputed from iphone's keypad. when i tapped button as in screen shot. how i can do that ? i don't want to use Textfield.
-(IBAction) buttonTapped {
[self.yourlabel setText:[textField text]];
}
Add a UITextField (you can name it hiddenTextField) some where, and set it hidden in view, so it'll become invisible to everyone, in viewDidLoad method of that UIViewController write,
[hiddenTextField becomeFirstResponder]; //it will make UIKeyBoard show on screen
On your UIButton action write,
- (IBAction)myAction {
myLabel.text = hiddenTextField.text;
//Don't forget to set `hiddenTextField` delegate to self.
[hiddenTextField resignFirstResponder];
}

dismiss Keyboard not working

Hi, I am not able to dismiss keyboard. I have a scroll view which have UITextFields on a it. I tried using
[self.view endEditing:YES];
And
[self.scrollView endEditing:YES];
I tried using resignFirstResponder on individual textfields but no use.
This issue only occurs when I tap a textfield which I am using as button when taped upon it I use
[textField resignFirstResponder];
but old one don't resign whatever I do like I tried using endEditing before I resigned the button like textfield. So my question is what could be the problem in my scenario and is there any way to forcefully dismiss keyboard?
If you want textField to act as button, use delegates.
textField.delegate=self;
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
return NO;
}

iOS hide default keyboard and open custom keyboard

I have an UITextview, when user taps on UITextview i need to hide the default keyboard. For that i have done,
[myTextView setEditable: NO];
So the keyboard is not shown, here i have created an Custom View with UIButton, i need to show this UIView when the user taps on UITextView, for that i have done,
textViewDidBeginEditing{
//Here i have added UIView as subview
}
But this method is not working because of,
[myTextView setEditable: NO];
and i need to close the UIView when user clicks the close button inside the UIView
You should be using resignFirstResponder instead of setting the UITextView to not editable. This will hide the system keyboard.
[myTextView resignFirstResponder];
If you want to use a different view for the keyboard then the system provided one then set inputView on the UITextView to the custom view you want to be used in place of the system keyboard.
myTextView.inputView = myCustomView;
Perhaps using textFieldShouldBeginEditing instead of setEditable: NO works?
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
//Here i have added UIView as subview
return NO;
}

resignFirstResponder programmatically [duplicate]

This question already has answers here:
Understanding resignFirstResponder with UITextField
(3 answers)
Closed 9 years ago.
How do I remove a keyboard from the view as a result of the return key being touched when the UITextField was created programmatically.
If the UITextField was called in the viewDidLoad I know how to do this, but the UITextField was created as a result of an -(IBAction).
I created my UITextField programmatically. I know the resignFirstResponder removes the keyboard. I have it set up to do so when the screen is taped outsie the keyboard. I also have it working to where if the user triggers the IBAction with the UIButton related to the UITextField the keyboard goes away. I also want to be able to hide the keyboard when the user selects return from the keyboard.
You need to make yourself a UITextFieldDelegate and implement:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
Make sure you set the textField's delegate to self when you create it.
You can use this:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
You'll need to set your text field's delegate to self first, though:
self.textField.delegate = self;
Or, you could right-click-drag from the text field in IB to little orange circle at the bottom.

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];
}
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;
}

Resources