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
2 answers

How to give text field change event for text filed on uitableview in swift?

I have a UITableView on each row it has a text field. When user type something on text field i want to trigger that textFieldDidChange or whatever. Basically when text field change i wanna calculate something how can i do that?I'm using swift. Here…
Anushka Madushan
  • 681
  • 2
  • 12
  • 31
1
vote
1 answer

How to reload scene after changing its physics world gravity based on user input?

I want to allow the user to change gravity based on their input in gravity text field and pass the input from view controller to a SKScene (PhysicsScene) but I don't know how to reload scene so that it would use the custom gravity by the user…
1
vote
2 answers

Bug? UILabel live updating by UITextFieldDelegate is off by one character

Here is a sample app to demonstrate the issue that I ran into: import UIKit class ViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var aTextField: UITextField! @IBOutlet weak var aTextLbl: UILabel! override func…
user5737558
1
vote
0 answers

How to use shouldChangeCharactersInRange to continuously format a number

I have a UITextField validate that converts a user's numeric input. For example, if the user types in a 1, it becomes 0.01. If the user types 12, it becomes 0.12. My code is working correctly when I have the validation code in…
May Yang
  • 523
  • 1
  • 5
  • 18
1
vote
0 answers

UITextField - Get text before editing changed

I set my text field to accept integer only but want to use UITextField inheritance rather than delegate of shouldChangeCharactersInRange. Is there any way to get text value before editingChanged called as using dropLast() won't work in case the…
Lawliet
  • 3,438
  • 2
  • 17
  • 28
1
vote
2 answers

Swift resigning TextView from first responder

I have a TextField and a TextView in my ViewController. The ViewController follows both UITextFieldDelegate and UITextViewDelegate and their delegate methods. I want to resign the TextField or the TextView from being the first responder when the…
1
vote
2 answers

textField delegates are not being called

Below mentioned are my textField delegate methods, I am using IQKeyBoardSwift for inteligent keyboard. I tried removing my keyboard but still I am not receiving call on any of my method accept 'begins touch' func textFieldShouldReturn(textField:…
1
vote
0 answers

UICollectionViewFlowLayout issues with collectionview and textfields

I have an app that uses a collectionview that scrolls horizontally, and has collectionviewcells inside of it. Everything was going fine until I tried to implement a login/register cell with 2 textfields in it using textfielddelegate. When I press on…
1
vote
1 answer

what's the code meaning? UITextFieldDelegate

How does this code work - func textFieldShouldReturn(_ textField: UITextField) -> Bool { if textField.resignFirstResponder() { textField.text = nil } return true } func textFieldDidEndEditing(_ textField: UITextField) { …
1
vote
1 answer

How to make visible Cursor on TextField when keyboard not visible in iOS

The text field cursor is only visible after calling textField.becomeFirstResponder() and is invisible after textField.resignFirstResponder(). But I want to make visible the cursor after textFieldDidEndEditing or before textFieldShouldBeginEditing.…
Litle Dev
  • 474
  • 1
  • 5
  • 18
1
vote
2 answers

Swift format text field when user is typing

I'm trying to format an expiry field so that it formats the text as follows: MM / YY I can get the textfield to add in the extra characters when the user is typing however when I come to delete the numbers the code will not allow you to go passed…
user7684436
  • 697
  • 14
  • 39
1
vote
1 answer

Working with UITextFieldDelegate and a custom input container

In my current application, I have created a custom input container for the users to enter comments. Please refer to the picture below. The textfield is set as the delegate for UITextFieldDelegate, and I would like to work with…
iMoment
  • 243
  • 1
  • 4
  • 14
1
vote
1 answer

How to find out why a UITextField ended editing?

I have a UITextField that can be set into editing mode. Normally, editing is ended by entering „Done“ on the keyboard. This calls textFieldDidEndEditing(_ textField: UITextField), where some housekeeping happens. In rare cases, however, an alert…
Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116
1
vote
1 answer

set delegate for textfields on UITableViewcell

I use "tags" for identifying textfields inside a UITableView in my swift code. I need to implement UITextFieldDelegate functions like textfieldshouldreturn and textFieldShouldBeginEditing. But in most examples, these delegate functions shows…
Vinod
  • 675
  • 3
  • 7
  • 25
1
vote
1 answer

When scrolling fast in UITableView and selecting cell, textfield delegate returns indexPath as nil and crashes

I have the structure of my TableViewController as such (mentioning for delegation purposes): ----View -----Scroll View ------Content View -------TableView --------TableViewCell I can get all of the rows and sections of my TableView to load…
Sami
  • 579
  • 5
  • 25