Questions tagged [uitextfielddelegate]

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

uitextfielddelegate
Filter by
Sorted by
Tagged with
641 votes
22 answers
420k views

UITextField text change event

How can I detect any text changes in a textField? The delegate method shouldChangeCharactersInRange works for something, but it did not fulfill my need exactly. Since until it returns YES, the ...
karim's user avatar
  • 15.5k
96 votes
10 answers
100k views

How shouldChangeCharactersInRange works in Swift?

I'm using shouldChangeCharactersInRange as a way of using on-the-fly type search. However I'm having a problem, shouldChangeCharactersInRange gets called before the text field actually updates: In ...
Fudgey's user avatar
  • 3,823
75 votes
17 answers
91k views

Switching between Text fields on pressing return key in Swift

I'm designing an iOS app and I want that when the return key is pressed in my iPhone it directs me to the next following text field. I have found a couple of similar questions, with excellent answers ...
lucas rodriguez's user avatar
60 votes
13 answers
68k views

Detect backspace Event in UITextField

I am searching for solutions on how to capture a backspace event, most Stack Overflow answers are in Objective-C but I need on Swift language. First I have set delegate for the UITextField and set it ...
Want Query's user avatar
  • 1,406
60 votes
4 answers
75k views

Cannot assign a value of type ViewController to a value of type UITextFieldDelegate?

Here's the error when I wrote the line self.MessageTextField.delegate = self: /ChatApp/ViewController.swift:27:42: Cannot assign a value of type 'ViewController' to a value of type '...
David's user avatar
  • 1,680
41 votes
10 answers
44k views

How to detect delete key on an UITextField in iOS 8?

I have subclassed UITextField and implemented the UIKeyInput protocol's deleteBackward method to detect backspace being pressed. This works fine on iOS 7 but not on iOS 8. deleteBackward is not ...
VNVN's user avatar
  • 511
36 votes
6 answers
17k views

Format UITextField text without having cursor move to the end

I am trying to apply NSAttributedString styles to a UITextField after processing a new text entry, keystroke by keystroke. The problem is that any time I replace the text the cursor will jump the very ...
Bernd's user avatar
  • 11.3k
33 votes
4 answers
45k views

Next/Done button using Swift with textFieldShouldReturn

I have a MainView that adds a subview (signUpWindow) when a sign up button is pressed. In my signUpWindow subview (SignUpWindowView.swift), I set up each field with a function, as an example: func ...
Amy Plant's user avatar
  • 686
31 votes
6 answers
44k views

Swift how to resign first responder on all uiTextfield

I would like to use resign the first responder on all uitextfield. I'm able to complete this by placing the uitextfields in an array but I wanted to avoid using the array. the resign should happen to ...
SwiftER's user avatar
  • 1,255
29 votes
7 answers
36k views

Allow only alphanumeric characters for a UITextField

How would I go about allowing inputting only alphanumeric characters in an iOS UITextField?
WalterF's user avatar
  • 1,345
28 votes
7 answers
43k views

UITextField lose focus event

I have an UITextField in a MyCustomUIView class and when the UITextField loses focus, I'd like to hide the field and show something else in place. The delegate for the UITextField is set to ...
Alexi Groove's user avatar
  • 6,676
23 votes
8 answers
13k views

How to detect when user used Password AutoFill on a UITextField

I've implemented all the app and server changes necessary to support Password Autofill on iOS 11, and it works well. I'd like it to work a little better. My username and password fields are ...
Mitch Cohen's user avatar
  • 1,581
22 votes
7 answers
38k views

Detecting a change to text in UITextfield

I would like to be able to detect if some text is changed in a UITextField so that I can then enable a UIButton to save the changes.
RGriffiths's user avatar
  • 5,792
22 votes
1 answer
22k views

iOS Swift Pass Closure as Property?

Let's say I have a custom UIView, lets call it MyCustomView. Inside this view is a UITextField property. Suppose my goal is to be able to create an instance of MyCustomView and add it to some view ...
Mike's user avatar
  • 9,825
22 votes
3 answers
7k views

UITextField delegate methods are not fired when setting text programmatically

I've created a custom input view for entering text into UITextField. Basically it's just custom designed number pad. I have textfields, on which I've set the inputView property to use my custom ...
kyurkchyan's user avatar
  • 2,318
21 votes
2 answers
6k views

swift 2.0 - UITextFieldDelegate protocol extension not working

I'm trying to add a default behavior on some UITextFieldDelegate's methods using protocol extensions like so : extension ViewController: UITextFieldDelegate { // Works if I uncommented this so I ...
Yaman's user avatar
  • 3,979
20 votes
2 answers
20k views

Action of the "Go" button of the ios keyboard

How do I bind an action to the Go button of the keyboard in iOS ?
Alexis's user avatar
  • 16.7k
18 votes
13 answers
44k views

How to move cursor from one text field to another automatically in swift ios programmatically?

func textFieldDidBeginEditing(textField: UITextField) { scrlView.setContentOffset(CGPointMake(0, textField.frame.origin.y-70), animated: true) if(textField == firstDigit){ textField....
Rakesh Mohan's user avatar
16 votes
7 answers
9k views

iOS 6 UITextField Secure - How to detect backspace clearing all characters?

In iOS 6 if you type text into a secure text field, change to another text field, then come back to the secure text field and hit backspace, all of the characters are removed. I am fine with this ...
crizzwald's user avatar
  • 1,037
15 votes
1 answer
7k views

iOS - Detect backspace in keyboard when UITextField is empty [duplicate]

Possible Duplicate: Detect backspace in UITextField I want to detect when backspace is pressed on the keyboard, even when a UITextField is empty. I tried to use ShouldChangeCharachtersInRange, ...
Blondy314's user avatar
  • 761
14 votes
3 answers
25k views

Properly Subclassing UITextField in swift

So i have these textfields that i realised that they all have same properties, so i created new class called "UserInputs" and extended from UITextField, everything works properly except one thing, ...
nikagar4's user avatar
  • 840
14 votes
8 answers
35k views

Why is textFieldDidEndEditing: not being called?

I've got a UITextField, and when text gets entered into that, I want to obtain the doubleValue from the text field and perform some computations and display them in a UITableView. The delegate for ...
Chris Cleeland's user avatar
14 votes
5 answers
38k views

Change custom text field background color and text color IOS Swift

I'm using following custom text field class to change appearance of the text field. Now I need to change text field's background color, text color and place holder color, when user start editing and ...
Arvin Jayanake's user avatar
13 votes
7 answers
8k views

Enabling done button after inserting one char in a textfield: textFieldDidEndEditing: or textFieldShouldBeginEditing: or?

I would like to enable the done button on the navbar (in a modal view) when the user writes at least a char in a uitextfield. I tried: textFieldDidEndEditing: enables the button when the previous ...
Sefran2's user avatar
  • 3,588
12 votes
3 answers
2k views

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

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, ...
Andrew's user avatar
  • 7,813
11 votes
5 answers
16k views

How can I edit a UILabel upon touching it in Swift?

I want to know how to edit the label of text while the app is running. Example: there will be label called "Tap to Change text." When the user clicks it, it will be editable and the user can input ...
Im Batman's user avatar
  • 1,876
10 votes
4 answers
16k views

Trying to bold titleLabel of UIButton in response to delegate method being called in iOS

I am working on an application where I am calling the UITextFieldDelegate method: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)...
syedfa's user avatar
  • 2,799
10 votes
5 answers
6k views

UITextFieldDelegate vs UITextField control events

If I want to handle changes to a UITextField, such as the user typing in it; it seems like this can be done either by assigning a delegate to that text field, and then having the delegate implement ...
GendoIkari's user avatar
  • 11.8k
10 votes
1 answer
3k views

TextField becomeFirstResponder Issue for tab key(Keyboard) action

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 ...
Balaji's user avatar
  • 261
9 votes
3 answers
5k views

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

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.
serge2487's user avatar
  • 441
9 votes
4 answers
3k views

iOS - validate user ip address during typing

So i want to validate the user ip during typing. In the VC i did the following : extension NetworkSettingsViewController: UITextFieldDelegate { func textFieldShouldReturn(_ textField: UITextField) ...
ironRoei's user avatar
  • 2,149
9 votes
1 answer
2k views

Swift why strcmp of backspace returns -92?

I was tried to detecting backspace inside of UITextfieldDelegate. And found this answer. https://stackoverflow.com/a/49294870/911528 And It working correctly. But I don't know what's going on inside ...
AutumnSky's user avatar
  • 394
8 votes
3 answers
10k views

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

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 '...
Architekt's user avatar
  • 2,170
8 votes
2 answers
5k views

How do I set the delegate for a text field in the interface builder to "files owner"?

I am trying to implement the : - (BOOL) textFieldShouldReturn:(UITextField *)textField method. For some reason it is not being called. I have set the text field to first responder in the code. I ...
Kex's user avatar
  • 8,240
8 votes
2 answers
2k views

Where to set UiTextField delegate method in custom UiView

Error occurs when I set UITextField delegate. My code is: import UIKit class UserAlertVC: UIView , UITextFieldDelegate { /* // Only override draw() if you perform custom drawing. // An empty ...
Gaurav's user avatar
  • 334
7 votes
8 answers
17k views

How to get UITableViewCell's index from its edited UITextField

I'm working on an iPhone based BI project. I have a UITextField in a UITextViewCell, the UITextFieldDelegate points to my UITableViewController, I haven't done any sub-classing for the ...
Zhao Xiang's user avatar
  • 1,633
7 votes
3 answers
10k views

How do I identify which textField triggered textFieldDidEndEditing on dynamically created UITableCell containing 2 uiTextFields?

I am on iOS 6 xcode 4.6.2 using storyboards. I am using a dynamic UITableView which consists of a number of cells each of which have two UITextFields on them. The two fields are defined in a custom ...
SimonTheDiver's user avatar
7 votes
2 answers
4k views

UIAlertController's textfield delegate does not get called

I have added a UITextField to UIAlertController, but shouldChangeCharactersInRange will get not fired. Why? I set the delegate. let alertController = UIAlertController(title: "", message: "xxx", ...
János's user avatar
  • 34k
7 votes
3 answers
11k views

How can I use Combine to track UITextField changes in a UIViewRepresentable class?

I have created a custom text field and I'd like to take advantage of Combine. In order to be notified whenever text changes in my text field, I currently use a custom modifier. It works well, but I ...
LondonGuy's user avatar
  • 10.9k
7 votes
2 answers
7k views

UITextField to Input Money Amount

I am developing a Point Of Sales app. So I would like to Let's say User input 100000 but I want it to automatically show up 100,000. and 1000000 become 1,000,000 The second problem is that, I don't ...
JayVDiyk's user avatar
  • 4,387
7 votes
4 answers
9k views

textFieldShouldEndEditing called multiple times

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 ...
Ben Gleeson's user avatar
7 votes
1 answer
3k views

Can't type in uitextfield because of - [general] connection to daemon was invalidated

When I tap in UITextfield to edit it, the message "connection to daemon was invalidated" shows up and the keyboard on my iPhone doesn't show up. I am unable to edit any UITextfield at the ...
David W Nam's user avatar
7 votes
5 answers
3k views

textFieldDidBeginEditing is called prematurely

I have an application in which I have to scroll up in case of the keyboard showing. to get the keyboard size, I'm registering the UIKeyboardWillShowNotification event like so: [[...
donald's user avatar
  • 489
6 votes
3 answers
12k views

Hiding the Keyboard on button click?

I am creating iPhone app which I show below. At the end of screen I have text field. I have added a delegate for the same. As it is number pad, I have added button seperately so that when button is ...
Fahim Parkar's user avatar
  • 31.3k
6 votes
5 answers
5k views

Disable copy, paste in UITextfield is not working in iOS 9.x

I created a text field in one class BBCustomUtility.h,.m class files and then +(UITextField*)createTextField: (CGRect)rect image:(NSString*)imageName tag:(int)tag secureText:(BOOL)entry placeh:(...
S P Balu Kommuri's user avatar
6 votes
3 answers
5k views

UITextField with "multiple" delegates

I'm trying to create a text field that would be able to respond to the following: -(BOOL)textFieldShouldEndEditing:(UITextField *)textField To do so i have a UITextField subclass which is a delegate ...
Marius's user avatar
  • 4,006
6 votes
2 answers
6k views

UITextField - Add a character/s after 1st character is entered while typing

I have a UITextField which will contain height value. I want to format the value of the field while the user is typing into the UITextField. e.g. if I want to enter the value as "5 ft 10", the flow ...
Durga Prasad Sahoo's user avatar
6 votes
8 answers
5k views

Issue in `becomeFirstResponder()` in swift

I have six textfields. Now if all my textfield are filled and tap on any textfield the it should always put focus on sixth textfield & show the keyboard. I have tried below code but it does not ...
TechChain's user avatar
  • 8,654
6 votes
2 answers
566 views

UITextField: can't type text but smilies, copy/paste, and backspace is fine

I think this is strange, I have made my own class that inherits from UIAlertView. In this class I add a UITableView as subview and the cells contains a UILabel and a UITextField. the class implements:...
kristoffer_o's user avatar
5 votes
5 answers
21k views

disable button when textfields are empty

hi im a beginner to programming and have been stuck on this task for ages and seem to be getting nowhere. basically i have several textfields that generates the input information on a different page ...
Ayub's user avatar
  • 110

1
2 3 4 5
12