uitextfielddelegate

TextField delegate shouldChangeCharactersInRange

。_饼干妹妹 提交于 2021-01-21 11:54:12
问题 Why doesn't the shouldChangeCharactersInRange update the textfield right away. It is 1 delayed by one character. For example, download this file: https://www.dropbox.com/s/goljs3d6lcxutxy/UITextField%20Tutorial.zip?dl=0 add the following code to func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { method print(textField.text) see how it is delayed by one character. I want it to be updated as I type the text not one

use uitextfield delegetate to fetch coredata binary data by its count number

一曲冷凌霜 提交于 2020-02-06 07:41:25
问题 My swift code saves 3 names to core data entity "username". I want to use uitextfield delegate to pull a specific string. So when the user enters 2 in the textfield. On the label labelName the name jessica Biel should appear. So the user enters a number into a textfield a string appears on the label. If number 1 is enter the 1st NSManagedObject into the core data entity userName. Link to project https://github.com/redrock34/jessicaBiel import UIKit import CoreData class ViewController:

UITextField delegate jumping to 100% CPU usage and crashing upon using keyboard shortcut

懵懂的女人 提交于 2020-01-29 04:40:26
问题 So, I have a UITextField subclass which is it's own Delegate and is crashing when keyboard shortcuts are used. It maxes out on CPU and doesn't give an error. Without assigning itself as it's Delegate , it works without problem. When it is assigned as it's Delegate , it crashes even when using none of the (optional) methods. Try it yourself: Subclass UITextField . - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.delegate = self; } return self; } It

Require a UITextField to take 5 digits [duplicate]

社会主义新天地 提交于 2020-01-05 10:17:25
问题 This question already has answers here : Set the maximum character length of a UITextField (44 answers) Closed 4 years ago . I have a UITextField set up to show a number pad. How do I require the user to enter exactly 5 digits? I poked around and saw I should use shouldChangeCharactersInRange but I'm not quite understanding how to implement that. 回答1: I'd just use this when the user leaves the textfield/validates with a button if ([myTextField.text length] != 5){ //Show alert or some other

How do I check UITextField values for specific types of characters e.g. Letters or Number?

空扰寡人 提交于 2020-01-02 13:20:33
问题 What I want to do is set some boolean in the if statement below to true if anything other than letters, numbers, dashes and spaces is contained in the textField. Then for an email field check for a valid email. This is how I'm checking for length: if countElements(textField.text!) < 2 || countElements(textField.text) > 15 { errorLabel.text = "Name must have between 2 and 15 characters." self.signUpView.signUpButton.enabled = false } else { errorLabel.text = "" self.signUpView.signUpButton

How do I check UITextField values for specific types of characters e.g. Letters or Number?

匆匆过客 提交于 2020-01-02 13:19:10
问题 What I want to do is set some boolean in the if statement below to true if anything other than letters, numbers, dashes and spaces is contained in the textField. Then for an email field check for a valid email. This is how I'm checking for length: if countElements(textField.text!) < 2 || countElements(textField.text) > 15 { errorLabel.text = "Name must have between 2 and 15 characters." self.signUpView.signUpButton.enabled = false } else { errorLabel.text = "" self.signUpView.signUpButton

How do I check UITextField values for specific types of characters e.g. Letters or Number?

筅森魡賤 提交于 2020-01-02 13:18:25
问题 What I want to do is set some boolean in the if statement below to true if anything other than letters, numbers, dashes and spaces is contained in the textField. Then for an email field check for a valid email. This is how I'm checking for length: if countElements(textField.text!) < 2 || countElements(textField.text) > 15 { errorLabel.text = "Name must have between 2 and 15 characters." self.signUpView.signUpButton.enabled = false } else { errorLabel.text = "" self.signUpView.signUpButton

How to pass data back to ViewController holding Container View and TableViewController that is embedded in the Container? Swift 3

和自甴很熟 提交于 2019-12-31 07:43:07
问题 How can I call func checkField when nextButton is tapped? If no field is empty in ManagedTableEleventhViewController, I'd like to segue to TwelvethViewController. I have a UIViewController ElevethViewController which holds a container view. The container view has an embed segue to a UITableViewController ManagedTableEleventhViewController . From ElevethViewController there is a Show segue to a UIViewController TwelevethViewController The View hierarchy looks like this: ElevethViewController

How to pass data back to ViewController holding Container View and TableViewController that is embedded in the Container? Swift 3

女生的网名这么多〃 提交于 2019-12-31 07:42:07
问题 How can I call func checkField when nextButton is tapped? If no field is empty in ManagedTableEleventhViewController, I'd like to segue to TwelvethViewController. I have a UIViewController ElevethViewController which holds a container view. The container view has an embed segue to a UITableViewController ManagedTableEleventhViewController . From ElevethViewController there is a Show segue to a UIViewController TwelevethViewController The View hierarchy looks like this: ElevethViewController