Is there a simple way to remove keyboard shortcut suggestions from a UITextField
?
It is possible to remove typing correction with: [textField setAutocorrectionType:UITextAutocorrectionTypeNo];
however this as no effect on shortcuts.
Affecting the sharedMenuController also does not squash this.
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender { [UIMenuController sharedMenuController].menuVisible = NO; return NO; }
You have to disable autocorrection on the text field/text/any other class that conforms to the UITextInputTraits protocol, which can be done through the autocorrectionType property.
The standard clear button is displayed at the right side of the text field as a way for the user to remove text quickly. This button appears automatically based on the value set for this property.
If you have a UITextField and you want to hide the keyboard when the user is pressing the return key, use the textFieldShouldReturn function. Be sure you have set the textField. delegate = self in your viewDidLoad() function.
Objective-C
textField.autocorrectionType = UITextAutocorrectionTypeNo;
Swift
textField.autocorrectionType = .no
Documentation https://developer.apple.com/library/ios/documentation/uikit/reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With