uitextfield

want to know ever time while pressing on keyboard back button during textfield editing ios

孤街浪徒 提交于 2019-12-02 05:57:34
In OTP, there are four textfields were used. Moving the cursor to the previous textfield while pressing on keyboard back button? To detect the backspace event in a UITextField, first you need to set up a delegate for the UITextField and set it to self. class ViewController: UIViewController,UITextFieldDelegate self.textField.delegate = self Then you use the delegate method below to detect if a backspace was pressed func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { func textField(_ textField: UITextField,

UITextField show cursor even when userInteractionEnabled is set to NO

别说谁变了你拦得住时间么 提交于 2019-12-02 05:41:48
I have a UITextField and it must blink the cursor anyway, even its userInteractionEnabled property is set to NO. I don't want the UITextField to becomeFirstResponder and show the keyboard. Now you may be asking: 1. If you want to hide the keyboard, why to show the cursor? A: The problem is that I need to show the user the UITextField is being edited, with a different/custom keyboard. 2. So why don't you use the inputView property? A: Because the keyboard in inputView comes up from bottom, and I want my custom keyboard in the center of the screen. So let's go to the real question: How can I

UITextField inside an UIAlertView not working in iOS4.1 and works in 3.0

被刻印的时光 ゝ 提交于 2019-12-02 04:46:11
I have a UITextField added to an UIAlerView (Kind of adding user to list with nick name, and nickname is asked by the alertview.). Thats work perfect in iOS3, But I cant type to that UITextField in iOS4.1. in iOS4.1 I do get focus to that textfield inside alertview, and keyboard appears, however typing doesn't work. Please help in this regard. In iOS 4 UIAlertViews will automatically be moved and sized to avoid the keyboard if they contain any UITextFields in their subviews so you don't have to move it yourself. Simply add a text field like so: UIAlertView *alert = [[UIAlertView alloc]

Adding a minus sign to the UITextField's .NumberPad keyboard

送分小仙女□ 提交于 2019-12-02 04:27:32
Fairly new to iOS development so forgive me for asking something that might be quite obvious. As you all know the UITextField's keyboard with keyboardType set to .NumberPad looks like the following... .NumberPad keyboard What I would like to do is replace the empty space in the lower left corner with a minus sign. Is this possible or does one need to write an entire custom keyboard to achieve this? Would really appreciate the help. Add a toolbar to your textfield inputAccessoryView and when the textfield will become the responder then the keyboard will show the toolbar (Swift 3.0): func

UITextField in custom UITableViewCell unexpectedly found nil

喜夏-厌秋 提交于 2019-12-02 04:26:21
I have a TableView with custom cells that have a TextField inside, unfortunately I get a Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value when I use them (press return or touch the screen outside the textField to get out of the placeholder). Here is my code : class WalletTableViewController: UIViewController, UITextFieldDelegate { var cryptosArray: [Cryptos] = [] override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self loadCryptoArray() } func loadCryptoArray() { if UserDefaults.standard.object(forKey: "cryptosArray") != nil { if let decoded =

How can I move to the previous UITextField if the “Backspace” button is pressed and the text field is blank and in Swift 4?

流过昼夜 提交于 2019-12-02 04:13:33
I am trying to figure this out. When I use the code below, I am able to move from one text field to the next and click the "Backspace" button but ONLY when the text field has text in there. My Question: How can I click the "Backspace" button when the text field is blank and move to the previous text field? Second Question: How do I get rid of the blinking blue line on the UITextField ? Below is the code that I have. Any help will be greatly appreciated! @objc func textFieldDidChange(textfield: UITextField) { let text = textfield.text! if text.utf16.count == 0 { switch textfield { case

Swift format text field when user is typing

落爺英雄遲暮 提交于 2019-12-02 03:33:49
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 two characters before adding in the " / " again. Is there a way I can recognise when the user is deleting and bypass the text field check? ExpiryOutlet.addTarget(self, action: #selector(ExpiryDidChange(_:)), for: .editingChanged) func ExpiryDidChange(_ textField: UITextField) { if textField == ExpiryOutlet { if textField.text != "" && textField.text?

Add a prefix to UITextField

隐身守侯 提交于 2019-12-02 03:27:47
问题 I want a '$' Sign in the text field which cannot be erased. A user should be able to enter values after it and if he presses backspace it should only erase the value he entered. The reason I can't use UILabel before it is because the text in UITextfield is center aligned and it grows to either side as the user enters values. Please provide any solution 回答1: Set the text field's text to "$" initially. Set the text field's delegate to some object of yours (probably the view controller

Retain Cycle (Strong reference) fix for custom uitextfield?

陌路散爱 提交于 2019-12-02 03:11:04
问题 I have a custom text field class, "loginTextFields". I recently noticed that The view controllers in which I use these text fields are not being deallocated, and I suspect that it has something to do with these text fields... Any guidance is greatly appreciated :) I've looked up quite a few stackoverflow posts but none really helped me out. The txt field class: class LoginTextFields: UITextField, UITextFieldDelegate { override init(frame: CGRect) { super.init(frame: frame) delegate = self

Disabling keyboard input when using a UITextField + UIPickerview

天涯浪子 提交于 2019-12-02 03:00:37
This project also click on the textfield pickerview opens, but the data shown above can be entered in the section. How can I turn it off? So just come to my choices below. If the textfield is clicked, I open the pickerview: import UIKit import NVActivityIndicatorView struct kategoriData { var text : String? var id : String? } class KonuEkleViewController: UIViewController,UITextFieldDelegate , NVActivityIndicatorViewable , UIPickerViewDataSource , UIPickerViewDelegate{ @IBOutlet weak var txtBaslik: UITextField! @IBOutlet weak var txtYazi: UITextView! @IBOutlet weak var txtLink: UITextField!