hiding keyboard ios [duplicate]
If you want to hide the keyboard when you tap a button and you have more than one UITextFields in your view, then you should use: [self.view endEditing:YES]; Tap anywhere on the view, and the keyboard will disappear.
If you want to hide the keyboard when you tap a button and you have more than one UITextFields in your view, then you should use: [self.view endEditing:YES]; Tap anywhere on the view, and the keyboard will disappear.
There is a couple of things you need to remember. The number #1 part developers forget to set is the delegate of the textField. If you are using the Interface Builder, you must remember that you need to set the delegate of the textField to the file Owner. If you are not using Interface Builder … Read more
Here’s an idea: modify the existing keyboard to your own needs. First, register to be notified when it appears on screen: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modifyKeyboard:) name:UIKeyboardWillShowNotification object:nil]; Then, in your modifyKeyboard method: – (void)modifyKeyboard:(NSNotification *)notification { UIView *firstResponder = [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(firstResponder)]; for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) for (UIView *keyboard in [keyboardWindow … Read more
The UITextField’s inputView property is nil by default, which means the standard keyboard gets displayed. If you assign it a custom input view, or just a dummy view then the keyboard will not appear, but the blinking cursor will still appear: UIView* dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; myTextField.inputView = dummyView; // Hide … Read more
You can do it starting from iOS 7 on a per UIResponder basis. There is textInputMode property in UIResponder class. It is readonly, but the documentation says: The text input mode identifies the language and keyboard displayed when this responder is active. For responders, the system normally displays a keyboard that is based on the … Read more
Figured I would post the snippet right here instead: Make sure you declare support for the UITextViewDelegate protocol. – (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if([text isEqualToString:@”\n”]) { [textView resignFirstResponder]; return NO; } return YES; } Swift 4.0 update: func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { if text == … Read more