Questions tagged [uitextfielddelegate]

The methods declared by the UITextFieldDelegate protocol allow the adopting delegate to respond to messages from the UITextField class.

The methods declared by the UITextFieldDelegate protocol allow the adopting delegate to respond to messages from the UITextField class. On UITextFieldDelegate, you can find the following methods:

Managing Editing

– textFieldShouldBeginEditing:

– textFieldDidBeginEditing:

– textFieldShouldEndEditing:

– textFieldDidEndEditing:

Editing the Text Field’s Text

– textField:shouldChangeCharactersInRange:replacementString:

– textFieldShouldClear:

– textFieldShouldReturn:

574 questions
2
votes
3 answers

How to detect UITextField cursor move without typing?

When a user only moves the cursor without typing a new word (i.e. (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange) replacementString:(NSString *)string does not get triggered), how do I detect this event?
TPWang
  • 1,322
  • 4
  • 20
  • 39
2
votes
3 answers

Textfield.text entered should have a specific format

I have a textfield and I want the text to be entered in it in a format: aa #### 1234 I know this should be done in shouldChangeCharactersInRange delegate method of textfield.nut I am not able to understand that how condition will be implemented on…
Prez
  • 227
  • 3
  • 12
2
votes
1 answer

Swift UICollectionView Textfields

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…
user7684436
  • 697
  • 14
  • 39
2
votes
3 answers

Restrict user to enter only seven comma separated words

I have a UITextfield in which I want user to enter comma separated text example : elephant,fox, etc, Also I want to restrict the user to enter at maximum 7 comma separated words. I have written this code in the delegate method of UITextfield -…
Avinash Sharma
  • 665
  • 1
  • 7
  • 23
2
votes
1 answer

How to make textfield functional inside a tableview on swift

I'm trying to create a tableview where each cell has multiple textfields. I was able to create a simple list with a textfield but when I press the textfield nothing happens. The keyboard does not popup and feels like the event is being captured by…
2
votes
1 answer

Handling delegate of UItextfield in UItableView

I have a UItextfield in one of the cell in my UItable, I want few steps can be execute after return from the text field: Clear out emptyspace at beginning and the end(Trim whitespace) resign first responder (hide the keyboard) set the cell…
CY.L
  • 35
  • 1
  • 5
2
votes
2 answers

How to set textfield minimum characters on swift 3

I'm looking for a way to minimize characters in textfield. Since the textfield is for username input, I want to make users input 4 characters minimum to 30 characters maximum. First, I made textfield shouldChangeCharactersIn to set maximum…
user2508528
  • 131
  • 1
  • 3
  • 9
2
votes
1 answer

UITextFiled - textFieldShouldBeginEditing being called for every textField

I've got UICollectionViewCell with multiple textFields. Every single delegate is connected (once), UITextFields got single property (no duplicates). Every single time I start editing UITextField, method textFieldShouldBeginEditing is being called…
Piotr Gawłowski
  • 189
  • 1
  • 10
2
votes
3 answers

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

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…
xxtesaxx
  • 6,175
  • 2
  • 31
  • 50
2
votes
0 answers

shouldChangeCharactersInRange Range.length Always 0

Question: For some reason in the TextField Delegate method shouldChangeCharactersInRange the range.length is always 0... My Code func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String)…
JoellyR
  • 153
  • 1
  • 17
2
votes
3 answers

In what situation, should I use _ as a parameter in swift

I am new to apple Swift.I am trying to build a demo app based on this tutorial. I have found that the app is not working. After several trial and fails, I have found that if I change the line of code: func textFieldDidEndEditing(textField:…
user3588276
  • 137
  • 1
  • 8
2
votes
3 answers

I'm implementing hashtag recognizer in UITextView but it never highlights two words with the same begining

I found this question: How to make UITextView detect hashtags? and I copied the accepted answer into my code. I also set up a delegate to my textview and then put this code: func textViewDidChange(textView: UITextView) { …
user3766930
  • 5,629
  • 10
  • 51
  • 104
2
votes
1 answer

textFieldShouldEndEditing delegate method is fired multiple times on a single text field object when instance of UIAlertController is executed

I have a view controller called LoginViewController that conforms to UITextFieldDelegate and have two text field objects namely Email and Password. There's an email validation function imposed on the Email text field and should the validation fails,…
yohannes
  • 1,022
  • 11
  • 13
2
votes
4 answers

UITextField accepting only one decimal point with max 3 digits before decimal point & max 2 digits after decimal point

I want to restrict UITextField to accept only one decimal point. Also maximum 3 digits are allowed before decimal point & maximum 2 digits allowed after decimal point. Please note that minimum digits can be 1 and decimal cant be entered a first. How…
hp iOS Coder
  • 3,230
  • 2
  • 23
  • 39
2
votes
2 answers

How to programmatically enter text into a UITextView by Clicking a Button using Swift

I have a UITextView and Two UIButtons ( ButtonOne and ButtonTwo). I would like to type text into this UITextView by clicking ButtonOne and ButtonTwo. For example, if I click ButtonOne it should type “apple” into the UITextView and after this if I…
Faheem Ahmad
  • 99
  • 10