Questions tagged [uitextfield]

A UITextField object is a control that displays editable text and sends an action message to a target object when the user presses the return button. You typically use this class to gather small amounts of text from the user and perform some immediate action, such as a search operation, based on that text.

A UITextField object is a control that displays editable text and sends an action message to a target object when the user presses the return button. You typically use this class to gather small amounts of text from the user and perform some immediate action, such as a search operation, based on that text.

In addition to its basic text-editing behavior, the UITextField class supports the use of overlay views to display additional information (and provide additional command targets) inside the text field boundaries. You can use custom overlay views to display features such as a bookmarks button or search icon. The UITextField class also provides a built-in button for clearing the current text. A text field object supports the use of a delegate object to handle editing-related notifications.

Resources:

8508 questions
52
votes
7 answers

How to set letter spacing of UITextField

I have an app in which the user has to type a four digit pin code. All digits have to be at a set distance from each other. Is there a way to do this if the PinTextField is a subclass of UIView? I know in a ViewController you could use…
KMV
  • 749
  • 1
  • 6
  • 16
52
votes
7 answers

Control cursor position in UITextField

I have a UITextField that I'm forcing formatting on by modifying the text inside the change notification handler. This works great (once I solved the reentrancy issues) but leaves me with one more nagging problem. If the user moves the cursor…
Jeremy
  • 849
  • 1
  • 7
  • 11
51
votes
5 answers

UIControlEventEditingChanged doesn't get fired when using setText of UITextfield

I am currently trying to track the states of a textfield. I am using a custom datePicker which sets the text via -setText [self.textField setText:[self.dateFormatter stringFromDate:self.date]]; Inside my textFieldDelegate I wrote the following…
Sebastian Boldt
  • 5,283
  • 9
  • 52
  • 64
50
votes
8 answers

UITextField text jumps

I have ViewController with 2 UITextField elements: Login and Password. I set delegate for these fields, which includes code below: func textFieldShouldReturn(textField: UITextField) -> Bool { if textField === self.loginField { …
user3237732
  • 1,976
  • 2
  • 21
  • 28
49
votes
5 answers

Easy way to disable a UITextField?

Is there an easy way to disable a UITextField in code? My app has 12 UITextField that are all turned on by default, but when a change is detected in my Segment Control I want to disable some of the UITextField depending on what Segment the user…
CC.
  • 793
  • 2
  • 9
  • 13
49
votes
2 answers

Why Is UITextField.text An Optional?

It starts out as an empty string instead of nil. Even when it is explicitly set to nil it remains an empty string. I don't get it. Perhaps to make it easy to clear by assigning nil? Writing code with it is clunky. var textField =…
Verticon
  • 2,419
  • 16
  • 34
49
votes
5 answers

Telling a UITextField to become first responder while embedded in a UITableViewCell

I have a UITextField that is a subview of a UITableViewCell. When my view loads, I want the text field to become first responder. I have a pointer to the text field in the table cell, so to do this I am trying: [myTextField…
Jasarien
  • 58,279
  • 31
  • 157
  • 188
48
votes
3 answers

How to set focus to an iOS text field?

How do you programmatically set focus to some UITextField in iOS? When you tap on a textfield, the keyboard pops up to begin editing the textfield. How can you give focus to a textfield and bring up the keyboard without requiring the user to tap on…
Ravi kumar
  • 601
  • 1
  • 6
  • 7
48
votes
5 answers

Multi-line user input in iOS: UITextField vs UITextView

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…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
48
votes
6 answers

How can I show the numeric keyboard by default on iPhone?

I'm trying the following with no luck. When the user click on a UiTextfield I need to change the keyboard view to the numeric view automatically, is this possible?
Pablo
  • 483
  • 1
  • 4
  • 4
46
votes
13 answers

Get UITableView to scroll to the selected UITextField and Avoid Being Hidden by Keyboard

I have a UITextField in a table view on a UIViewController (not a UITableViewController). If the table view is on a UITableViewController, the table will automatically scroll to the textField being edited to prevent it from being hidden by the…
Lauren Quantrell
  • 2,647
  • 6
  • 36
  • 49
45
votes
13 answers

Text in UITextField moves up after editing (center while editing)

I have a strange problem. I have an UITextField in which the user should write the amount of something, so the field is called "amountField". Everything looks fine, when the user starts editing the textfield the text is in the vertical and…
Dominik Hadl
  • 3,609
  • 3
  • 24
  • 58
45
votes
13 answers

Email validation on textField in iOS

In iOS App, how to add Email validation on UITextField?
ios
  • 6,134
  • 20
  • 71
  • 103
45
votes
4 answers

Placeholder text not centered for UITextField created programmatically

I am creating a UITextField programmatically and placing it inside a UIView. The font size is set to 15.0f (system font). But the placeholder that appears is not centered in the text view. Any one know how to resolve this? I found some references…
lostInTransit
  • 70,519
  • 61
  • 198
  • 274
45
votes
10 answers

Setting maximum number of characters of `UITextView ` and `UITextField `

I'd like to set a maximum number of characters allowed to be typed both in a UITextView and a UITextField. This number will be then shown in a little label (for user's reference, Twitter Style.)
biggreentree
  • 1,633
  • 3
  • 20
  • 35