uitextfield

Assigning Character Limit to a Specific UITextField

ⅰ亾dé卋堺 提交于 2019-12-02 15:41:01
问题 The following code works but applies to all TextFields. How can I limit it to one specific TextField? Code: func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let currentCharacterCount = (textField.text?.characters.count) ?? 0 if (range.length + range.location > currentCharacterCount){ return false } let newLength = currentCharacterCount + string.characters.count - range.length return newLength <= 9 } 回答1: Assuming

how to create uitextfield dynamically using for loop

纵饮孤独 提交于 2019-12-02 15:35:54
问题 I try to create the uitextfield dynamically, but i can't create the textfield name.Anybody knows please help me. 回答1: Assign tag for each UITextField.. then access the textField using UITextField *tf=(UITextField *)[yourView viewWithTag:tag]; 回答2: from How do I create a text field? To create a text field, use the UITextField class, as shown in Listing 11. Listing 11: Creating a text field CGRect textFieldFrame = CGRectMake(0.0, 0.0, 100.0, 30.0); UITextField *textField = [[UITextField alloc]

Multi-line user input in iOS: UITextField vs UITextView

痴心易碎 提交于 2019-12-02 15:08:38
I need to show users a multi-line text input "box" with a height greater than the standard height of a UITextField . What the best or most correct approach should be?: Using a UITextField and change its height in code or by applying a certain height constraint. Using an editable UITextView . This is multi-line but it has no placeholder by default, I guess I should implement that feature in code. UITextField is specifically one line only. Use UITextView instead for multiline text. To implement the placeholder in UITextView use this logic/code. First set the UITextView to contain the placeholder

How to open the keyboard automatically on UITextField?

岁酱吖の 提交于 2019-12-02 14:50:47
I have a very simple table and when tocuh a cell it opens a new view with one UITextfield. All I want is that the keyboard will automatically opens, without the user have to touch the UITextfield. Its all done in Interface Builder, so I am not sure how I do this. I guess I need to set the focus at some point ? Thanks To cause the keyboard to show up immediately you'll need to set the text field as the first responder using the following line: [textField becomeFirstResponder]; You may want to place this in the viewDidAppear: method. Swift 3 & 4: override func viewDidAppear(_ animated: Bool) {

Change of UITextField placeholder color

谁说胖子不能爱 提交于 2019-12-02 14:48:14
How to dynamically change placeholder color of the UITextField ? This is always the same system color. No option in xib editor. From Docs @property(nonatomic, copy) NSAttributedString *attributedPlaceholder This property is nil by default. If set, the placeholder string is drawn using a 70% grey color and the remaining style information (except the text color) of the attributed string. Assigning a new value to this property also replaces the value of the placeholder property with the same string data, albeit without any formatting information. Assigning a new value to this property does not

Swift format text field when user is typing

六眼飞鱼酱① 提交于 2019-12-02 14:13:33
问题 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

UIScrollView not scrolling with UItextfields

[亡魂溺海] 提交于 2019-12-02 13:45:00
问题 I am making a normal view where users can update their profiles. I followed these steps to make that view Created a new UIViewController with xib file Added a UIScrollView in super view Added almost 9 UITextField and 1 small UIWebView Satisfied Autolayout constraints like top UITextField will have top, left, right and height constrains and same for all the following controls but last UITextField have top, left, right, bottom and height constraints. Now all the constraints are applied and

Pass data from one ViewController to another ViewController using NSUserdefaults

我怕爱的太早我们不能终老 提交于 2019-12-02 13:35:45
I need to data from one ViewController to another ViewController Here I've Multiple Textfields in first ViewController then it will passed the SecondViewController in Whatever Data i entered in FirstViewController. Can You Please suggest me. this is for storing NSString *verifyStatus=@"Y"; [[NSUserDefaults standardUserDefaults]setObject:verifyStatus forKey:@"verify_status"]; [[NSUserDefaults standardUserDefaults] synchronize]; for retrieving NSString *verify_status = [[NSUserDefaults standardUserDefaults]stringForKey:@"verify_status"]; You can also use property for this... Because It's easy ..

iPhone inputting NSUserDefaults into a UITextField

浪子不回头ぞ 提交于 2019-12-02 13:19:49
问题 I am writing a program where I where the first time a user runs it - they will have to fill out about 10 different UITextFields. I am trying to save the fields so that on subsequent runs of the program that whatever they previously put will already be displayed in those UITextFields so the wont have to re-input it in - unless they want to edit something in which case they still have that option. I think that I have figured out a good way to save the strings using NSUserDefaults but now I am

UITextField in custom UITableViewCell unexpectedly found nil

淺唱寂寞╮ 提交于 2019-12-02 13:19:08
问题 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() }