uitextfielddelegate

UIAlertController utility class fails to call UITextField delegate or target but works in UIViewController

我怕爱的太早我们不能终老 提交于 2019-12-11 04:23:57
问题 I encountered a strange issue and maybe it is only a lack of knowledge about Swift 3.0 / iOS 10 so hopefully you can guide me into the right direction or explain to me what I'm doing wrong. HOW IT CURRENTLY WORKS I am trying to create a UIAlertController with style .alert so I can get a user text input for my app. My requirements are that the text must not be empty and if there was a text there before, it must be different. I can use the following code to achieve what I want: //This function

iOS - validate user ip address during typing

萝らか妹 提交于 2019-12-10 17:35:48
问题 So i want to validate the user ip during typing. In the VC i did the following : extension NetworkSettingsViewController: UITextFieldDelegate { func textFieldShouldReturn(_ textField: UITextField) -> Bool { self.staticMask.resignFirstResponder() self.staticGateway.resignFirstResponder() self.staticIp.resignFirstResponder() self.staticDns.resignFirstResponder() return true } func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) ->

UIAlertController's textfield delegate does not get called

不打扰是莪最后的温柔 提交于 2019-12-10 15:47:58
问题 I have added a UITextField to UIAlertController, but shouldChangeCharactersInRange will get not fired. Why? I set the delegate. let alertController = UIAlertController(title: "", message: "xxx", preferredStyle: .Alert) self.presentViewController(alertController, animated:true, completion:nil) let textField = UITextField() textField.delegate = self alertController.addTextFieldWithConfigurationHandler(nil) and in the same class, the delegate: func textField(textField: UITextField!,

textFieldShouldEndEditing called multiple times

旧城冷巷雨未停 提交于 2019-12-10 13:17:15
问题 I am working on a view that has multiple UITextField objects. My view controller serves as the UITextFieldDelegate , and I've implemented the (BOOL)textFieldShouldEndEditing:(UITextField *)textField method to save and validate the record being displayed. If the user clicks on the "Done" button after editing an item and the save/validate fails, then a UIAlertView is displayed and the user is kept on the UITextField that fails validation. My problem is this -- when a user clicks from the

is it possible to know if user is typing or deleting characters in a textfield?

青春壹個敷衍的年華 提交于 2019-12-10 12:46:36
问题 I am using the text field delegate method "shouldChangeCharactersInRange" and I wanted to know if there is any way to tell if user is deleting characters or typing characters? Anyone know? thanks. 回答1: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (range.length > 0) { // We're deleting } else { // We're adding } } 回答2: Logic: For finding deletion you need to build a string after each letter type then you can

Warning about assigning to id<UITextFieldDelegate> when I'm conforming to the protocol

允我心安 提交于 2019-12-08 16:27:14
问题 My view controller is conforming to UITextFieldDelegate, yet when I try and set the .delegate field of my text field to self, I get the warning: "Assigning to 'id' from incompatible type 'AddReviewViewController *const __strong'" My header file is this: #import <UIKit/UIKit.h> @interface AddReviewViewController : UIViewController <UITextFieldDelegate> @property (nonatomic) int storeID; @end So as you can see, I have it declared to conform to the protocol. In the .m file, I have this:

TextField becomeFirstResponder Issue for tab key(Keyboard) action

删除回忆录丶 提交于 2019-12-08 15:46:59
问题 I have a view in XIB where i used several text fields in it. Let say the first text field becomes first responder as soon as the view gets loaded in the window. If i press tab key in my machine's keyboard to navigate to next text field ;apart from the immediate text field, all other text fields are also becomes first responder and the textfield begin editing delegate menthod gets called for all the text fields. What could be the issue ? This will occur not only in simulator when we use

textFieldDidEndEditing firing “too late”

风流意气都作罢 提交于 2019-12-08 02:49:42
问题 I have a multiview process the user is entering in data and I'm saving it to the model class properties each step along the way. I use textFieldDidEndEditing to check if the input is valid, and if so, saves the entered data. On the view I have a continueButtonClicked event that checks to see if all the validations pass and if so loads the next view. I do NOT set the properties of the model here, because I think I shouldn't have to since each field is saved to the model 1 field at a time.

Swift UICollectionView Textfields

懵懂的女人 提交于 2019-12-06 15:43:07
I have a bunch of UITextFields living inside a collection view in different cells (around 7). I'm looking for a way to delegate the responsibility of validating these fields to an internal service class. Is there a way in which I can do this without causing controller bloat? What I've partially tried is to create an object and then assign the Textfield delegates to this object. However I struggled on linking the two together (able to access the textField.text property to validate and add the output into a struct). Is there a cleaner, more efficient way or am I looking at a long Controller?

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

送分小仙女□ 提交于 2019-12-06 04:28:21
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.enabled = true } This if statement is inside the UITextFieldDelegate method textFielddidEndEditing. I have