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

Is this a hacky way to go to the next UITextField (using textFieldShouldReturn)?

- (BOOL)textFieldShouldReturn:(UITextField *)sender { if(sender.returnKeyType == UIReturnKeyNext){ // Make something else first responder }else if(sender.returnKeyType == UIReturnKeyGo){ // Do something }else{ …
rnystrom
  • 1,906
  • 2
  • 21
  • 47
2
votes
1 answer

Respond to specific key press in UITextField (UIViewRepresentable)

I would like to respond to keyboard presses in a UITextField wrapped as UIViewRepresentable. This is the code for the wrapper view: import SwiftUI import UIKit struct ContentView: View { @State var text: String = "Hello." var body:…
2
votes
1 answer

iOS keyboard: How can I start with a disabled done/return/go button on the keyboard and KEEP it disabled until the validation requirements are met?

I've got a text field delegate setup which disables/enables the done button on keyboard when certain conditions are met (between 5 and 15 characters, not just whitespace, etc...) using the "inputDelegate.returnKeyEnabled" key (which is wrapped by…
Mercutio
  • 1,152
  • 1
  • 14
  • 33
2
votes
0 answers

Xcode, textfield delegate, error on line textField.delegate = self

It's my first time creating an app with Xcode, and I have come across an error I can't figure out. The fatal error: Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value, occurs on line 29. I've seen other…
Patrick
  • 41
  • 6
2
votes
2 answers

SwiftUI Dismiss Keyboard from UITextField

So for my own reasons, I need the full control that UITextField and its delegates would normally offer, but the screen it's being added to is written with SwiftUI. Needs a .decimal keyboard, so no Return Key. I have only 2 issues remaining, 1 of…
2
votes
1 answer

Why is setDelegate not working for UITextFieldDelegate, but working via Interface Builder

I have the following code below, and I can't figure out why the textFieldShouldReturn method is not being called. When I use IB to create the connection to the delegate, it works, but when done programmatically, the log statement is not being…
Praveen R.
  • 241
  • 4
  • 15
2
votes
2 answers

textFieldDidEndEditing is not called in swift

I have a textfield in my tableview cell. When I am entering something and click on the submit button, I want to save the text in a struct to use it in other view controller. But the problem is , when I am clicking the submit button for the first…
Tapan Raut
  • 850
  • 6
  • 17
2
votes
1 answer

iOS UITextField textfield empty after selecting autofill address from contacts

I have a UITextField where the user enters an address and selects one of the matching locations that shows from MKLocalSearchCompleter. If the user selects an address from the autofill option as shown below, the textField is empty. If the user then…
FSUWX2011
  • 355
  • 1
  • 3
  • 8
2
votes
1 answer

How do I make my textField border change to a different color every-time it is selected?

I've created a custom textField class that I'm using throughout my app, but I want to know how I can change the border color to red every-time a field is selected without having to implement a delegate on each view controller that the textField…
mpc75
  • 937
  • 9
  • 22
2
votes
1 answer

iPhone: Is it safe to call textViewDidChange?

I'm looking at code in a UIViewController that conforms to the UITextViewDelegate protocol and has an instance variable called someTextView. someTextView.text = @"some text"; [self textViewDidChange:someTextView]; Is that safe? That doesn't look…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
2
votes
2 answers

make bottom line view colourful when i am writing inside textfield in ios swift

I have to make bottomline view colorful when i am trying to update my textfield. After leaving that box color of line should take default color.I tried this but not works for all fields.I have set delegate of textfield also. func…
blackstorm
  • 60
  • 10
2
votes
3 answers

Which would be the better way to pass values to viewmodel from viewcontroller

This question might seem basic, yet I am posting it to get suggestions. Following is a sample login module using MVVM pattern. The viewcontroller code is as follows. class ViewController: UIViewController { private var loginviewmodel =…
Sujal
  • 1,447
  • 19
  • 34
2
votes
0 answers

Swift 4 UiTextView - delete a word inside textView on button click

Is there a way to delete a specific word inside a UITextView? let's say for example that in a textView the user wrote: "Hello my nome is john". As soon as he finished typing he noticed that he mistyped a word. Lets' say that there is an array…
Marco
  • 1,051
  • 1
  • 17
  • 40
2
votes
1 answer

Design Approach for Subclassing UITextField with default behaviors in delegate methods

I have subclassed the UITextField class so I can provide some built-in functionality for my application. I've changed the appearance to provide only an underline border for the UX design. Also, I want to use this control in situations where there…
Shawn
  • 406
  • 4
  • 12
2
votes
1 answer

TPKeyboardAvoiding scrollview defaults to wrong return key type 'Done' in iOS not UIReturnKeyNext

I have used this keyboard avoiding library https://github.com/michaeltyson/TPKeyboardAvoiding in many iOS projects.It works as expected but in a project it is producing a weird issue where return key title is always 'Done' instead of…
Waseem05
  • 1,184
  • 1
  • 13
  • 15