uitextfield

Create max character length in UITextField using IBInspectable [duplicate]

冷暖自知 提交于 2020-06-17 09:45:14
问题 This question already has answers here : Limiting characters and character length in textField(_:shouldChangeCharactersInRange:replacementString:) (2 answers) Closed 13 days ago . I want to create a max length to my textfield with IBInspectable , I see a answer to this on a question here but I'm getting an error saying Expression type '()' is ambiguous without more context , My code was import UIKit private var __maxLengths = [UITextField: Int]() extension UITextField { @IBInspectable var

SwiftUI inputAccesoryView Implementation

余生颓废 提交于 2020-06-11 11:47:11
问题 I am trying to implement an inputAccessoryView on a TextField in SwiftUI. The goal is to have a "Done" Button appear above the Keyboard which when pressed gets rid of the keyboard (i.e. resignFirstResponder()). I came across the following Medium article which purports to implement this behavior exactly as I would require, however, I am struggling to get it working. Medium link containing method to be implemented. I have tried to implement this in a blank XCode project, my code compiles,

SwiftUI inputAccesoryView Implementation

烂漫一生 提交于 2020-06-11 11:46:10
问题 I am trying to implement an inputAccessoryView on a TextField in SwiftUI. The goal is to have a "Done" Button appear above the Keyboard which when pressed gets rid of the keyboard (i.e. resignFirstResponder()). I came across the following Medium article which purports to implement this behavior exactly as I would require, however, I am struggling to get it working. Medium link containing method to be implemented. I have tried to implement this in a blank XCode project, my code compiles,

How to change UITextField keyboard type to email in Swift

那年仲夏 提交于 2020-06-09 07:48:27
问题 In objective-c I can just say the following. [self.promoTextField setKeyboardType:UIKeyboardTypeEmailAddress]; I tried googling it but just get ways to do it in objective-c. 回答1: Try this : Swift 3 self.promoTextField.keyboardType = UIKeyboardType.emailAddress Swift < 3 self.promoTextField.keyboardType = UIKeyboardType.EmailAddress 回答2: The documentation about UITextInputTraits, a protocol adopted by UITextField , says it's still here: optional var keyboardType: UIKeyboardType { get set } And

How to change UITextField keyboard type to email in Swift

ぐ巨炮叔叔 提交于 2020-06-09 07:48:04
问题 In objective-c I can just say the following. [self.promoTextField setKeyboardType:UIKeyboardTypeEmailAddress]; I tried googling it but just get ways to do it in objective-c. 回答1: Try this : Swift 3 self.promoTextField.keyboardType = UIKeyboardType.emailAddress Swift < 3 self.promoTextField.keyboardType = UIKeyboardType.EmailAddress 回答2: The documentation about UITextInputTraits, a protocol adopted by UITextField , says it's still here: optional var keyboardType: UIKeyboardType { get set } And

Swift Pulse Animation

久未见 提交于 2020-05-25 05:31:41
问题 i'm trying to make a pulse animation, i've found this: ios - how to do a native "Pulse effect" animation on a UIButton and it was useful, but i need something else, so i have textfield, UITextField which has border, when you focus on it i want the border to change color, but in specific way i want it to start from center and then spread, i could not find the animation so i will try to demonstrate it by text:B = Black Y = Yellow. this is border: BBBBBBB border gets focused: BBBYBBB BBYYYBB

iOS/Swift: how to detect touch action on a UITextField

给你一囗甜甜゛ 提交于 2020-05-25 03:23:07
问题 I would like to detect the touch action on a UITextField. It seems the "Touch Up Inside" action is not fired by touching inside the textfield. 回答1: It seems "Touch Up Inside" is not enabled for UITextField , but "Touch Down" works. So the solution is as follows: Swift 4.x myTextField.addTarget(self, action: #selector(myTargetFunction), for: .touchDown) @objc func myTargetFunction(textField: UITextField) { print("myTargetFunction") } Swift 3.x myTextField.addTarget(self, action: #selector

swift how to suggest user email in uitextfield as autocomplete

我只是一个虾纸丫 提交于 2020-05-14 01:58:57
问题 Rather than showing autocomplete words I would like to show the autocomplete of the user emails for example example@domain.com This happens if I go to https://www.superbru.com/beta/register.php in Safari I get my email address suggested to me in the autocomplete box. This is how I set up my textfield but still no email being suggested. private let emailTextField: UITextField = { let textField = UITextField() textField.height(equalTo: 45) textField.keyboardType = .emailAddress textField

Why textFieldShouldReturn is still working when i return false?

心已入冬 提交于 2020-05-08 03:50:08
问题 I am hiding keyboard on return key pressed by implementing function textFieldShouldReturn and calling resignFirstResponder() inside this function. It works perfectly but when I return false in this function, still then keyboard is hiding. Now here I do not understand that what is use of returning true or false if keyboard is hiding in both case? 回答1: The keyboard is being dismissed due to the call to resignFirstResponder . It has nothing at all to do with the return value of

How do I avoid unwanted extra spaces inserted by dictation into UITextField

时间秒杀一切 提交于 2020-04-17 20:28:12
问题 I have a UITextField for the userid field in a "create account" scenario. I want the userid to only contain alphanumeric characters without any whitespace. I made my view controller to be a UITextFieldDelegate and implemented the shouldChangeCharctersIn function (see code below) to only return true for alphanumerics. I set my controller to be the delegate for the username text field. Everything works as expected unless copy/paste or dictation is involved. In this case, it almost works as