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
1
vote
1 answer

UITextFieldDelegate wasn't called when Undo key in iPad keyboard is pressed

There is this "undo" key on the iPad keyboard. I have a UITextField *textField where, textField.placeholder = @"Input"; Assumed that textField is not empty (textField.text = @"Something";), as I touched the textField and it became firstResponder, 1,…
rae148
  • 87
  • 1
  • 5
1
vote
1 answer

Can an object subscribe to its own notifications?

For example, a UITextField cannot be its own delegate, but is it OK to just have it register itself as an observer of its own notifications? Looks weird but seems to work fine. Thoughts? // MyTextField.h @interface MyTextField :…
1
vote
2 answers

UITextField not resigning keyboard

I've been bashing my head against the walls for some time now and still I haven't managed to break this problem. I have a modalViewController with on it a UITextField (let's call it myTroubleMaker) and several other non-important components. When I…
1
vote
2 answers

How to enable addButton when corresponding textField has 3+ characters typed in?

I have a textField and a submit button. The submit button is disabled by default and should only be enabled if textField has 3+ characters typed into it. My code: class AddNameVC: UITableViewController, UITextFieldDelegate { @IBOutlet weak…
CalebGates
  • 35
  • 5
1
vote
1 answer

textField:shouldChangeCharactersInRange:replacementString:

How can I correct this code. I want only numbers and range should be not exceed to 10. My code is - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSUInteger newLength…
Lion
  • 872
  • 1
  • 17
  • 43
1
vote
2 answers

UITextFieldDelegate of nested UITextFields not being called

I have a subclass of a UIView (MyView) that has some UITextField as subviews. MyView implements the UITextFieldDelegate protocol in order to be notified when the textfields are clicked. This was working well. Now I need to place the textfields in a…
strave
  • 1,491
  • 2
  • 16
  • 26
1
vote
1 answer

How to detect otp type empty textfield swift ios

I'v ten textfields like otp for mobile number.I've handled all cases except like if user write digit in first textfield and focus goes to second textfield.Second textfield is empty and when i press the delete button focus not goes to pervious…
Shaikh
  • 47
  • 4
1
vote
2 answers

custom percentage field UiTextField

i have a text field delegate method my use cases are :- if (.) dot is not there limit input to two characters because 100% should not be discount. if user input is 1.99 how can update the delegate method that it should take two numbers after…
Wahid Tariq
  • 159
  • 10
1
vote
1 answer

How to listen for escape key in UITextField on MacCatalystApp?

I'm working on a MacCatalyst app. I want to listen for escape key when user is editing a UITextField. I can listen to return key by accepting UITextFieldDelegate with method func textFieldShouldReturn(_ textField: UITextField) -> Bool { } Also the…
1
vote
1 answer

How to get currently entering text from UITextField Delegate?

I have used this delegate method but it's not returning last character which I entered. func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool Eg. Current Text field string is…
Ashvin
  • 8,227
  • 3
  • 36
  • 53
1
vote
1 answer

Swift - app crash when presenting popover as already presented

I have a textfield which, as user types in it, triggers a popover to be presented with a list of suggested values which the user can select from. Here is the textfield: lazy var iata: CustomTextField = { let field = CustomTextField( …
DevB1
  • 1,235
  • 3
  • 17
  • 43
1
vote
3 answers

UitextField shifts control to next textField upon using keyboard input

I am new to iPhone programming. I have two textfields in iPhone with numberPad Keyboard type and i am trying to implement a simple logic that on typing a single digit using numberPadKeyBoard, the control should shift to next textField i.e. second…
Vik
  • 488
  • 2
  • 10
  • 19
1
vote
1 answer

UITextField shouldChangeCharactersInRange stops getting called if I press backspace for a long time

If I type a very long text in my UITextField, for example: 123456789012345678901234567890. Now if I press the backspace and leave it pressed, then the shouldChangeCharactersInRange is called for some characters in the beginning. But, then when the…
Pria
  • 2,743
  • 4
  • 27
  • 30
1
vote
0 answers

Listening UITextField in the background even if the app or keyboard extension is not active

How can I write an application that listens to the text field in messaging applications such as Whatsapp, iMessage and captures the entries according to a predetermined format (for example: there is a * character at the beginning and end of the…
1
vote
1 answer

How to bind UITextField clear button with RxSwift

I need to handle UITextField statuses. So I bind my emailTextField with this way Observable.combineLatest( emailTxf.rx.controlEvent(.editingDidBegin), emailTxf.rx.controlEvent(.editingChanged), …
User18474728
  • 363
  • 2
  • 11