Disable UITextField Predictive Text

Setting the autoCorrectionType to UITextAutocorrectionTypeNo did the trick Objective-C textField.autocorrectionType = UITextAutocorrectionTypeYes; textField.autocorrectionType = UITextAutocorrectionTypeNo; Swift 2 textField.autocorrectionType = .Yes textField.autocorrectionType = .No Swift 3 textField.autocorrectionType = .yes textField.autocorrectionType = .no SwiftUI textField.disableAutocorrection(true) textField.disableAutocorrection(false)

UITextfield leftView/rightView padding on iOS7

A much simpler solution, which takes advantage of contentMode: arrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”down_arrow”]]; arrow.frame = CGRectMake(0.0, 0.0, arrow.image.size.width+10.0, arrow.image.size.height); arrow.contentMode = UIViewContentModeCenter; textField.rightView = arrow; textField.rightViewMode = UITextFieldViewModeAlways; In Swift 3, let arrow = UIImageView(image: UIImage(named: “arrowDrop”)) if let size = arrow.image?.size { arrow.frame = CGRect(x: 0.0, y: 0.0, width: size.width + 10.0, … Read more

how to add an action on UITextField return key?

Ensure “self” subscribes to UITextFieldDelegate and initialise inputText with: self.inputText.delegate = self; Add the following method to “self”: – (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == self.inputText) { [textField resignFirstResponder]; return NO; } return YES; } Or in Swift: func textFieldShouldReturn(_ textField: UITextField) -> Bool { if textField == inputText { textField.resignFirstResponder() return false } return … Read more

How to add TextField to UIAlertController in Swift

Swift 5.1 alert.addTextField { (textField) in textField.placeholder = “Enter First Name” } Use this code, I am running this code in my app successfully. @IBAction func addButtonClicked(sender : AnyObject){ let alertController = UIAlertController(title: “Add New Name”, message: “”, preferredStyle: UIAlertControllerStyle.Alert) alertController.addTextFieldWithConfigurationHandler { (textField : UITextField!) -> Void in textField.placeholder = “Enter Second Name” } let … Read more

How to make return key on iPhone make keyboard disappear?

First you need to conform to the UITextFieldDelegate Protocol in your View/ViewController’s header file like this: @interface YourViewController : UIViewController <UITextFieldDelegate> Then in your .m file you need to implement the following UITextFieldDelegate protocol method: – (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } [textField resignFirstResponder]; makes sure the keyboard is dismissed. Make sure you’re … Read more

Getting the Value of a UITextField as keystrokes are entered?

It turns out, the easiest way to do this is using Interface Builder: Add a IBAction (to the ViewController, say, as in this case) Ctrl-Click (or right click) on the UITextField in Interface Builder Connect the “Editing Changed” event to the File’s Owner’s IBAction added in the first step. Works like a charm 🙂 (I … Read more

How to disable UITextField editing but still accept touch?

Using the textfield delegate, there’s a method – (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string Return NO from this, and any attempt by the user to edit the text will be rejected. That way you can leave the field enabled but still prevent people pasting text into it.

How to dismiss keyboard iOS programmatically when pressing return

The simple way is to connect the delegate of UITextField to self (self.mytestField.delegate = self) and dismiss the keyboard in the method textFieldShouldReturn using [textField resignFirstResponder]; Another way to dismiss the keyboard is the following: Objective-C [self.view endEditing:YES]; Swift: self.view.endEditing(true) Put [self.view endEditing:YES]; where you would like to dismiss the keyboard (Button event, Touch event, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)