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
85
votes
9 answers

How to add a 'Done' button to numpad keyboard in iOS

So, the numpad keyboard doesn't come with a 'Done' or 'Next' button by default so I'd like to add one. In iOS 6 and below there were some tricks to add a button to the keyboard but they don't seem to be working in iOS 7. First I subscribe to the…
George McKibbin
  • 1,291
  • 1
  • 11
  • 16
82
votes
28 answers

How to toggle a UITextField secure text entry (hide password) in Swift?

I currently have a UITextfield with an eye icon in it that when pressed is supposed to toggle the secure text entry on and off. I know you can check mark the "secure text entry" box in the attributes inspector but how to do it so it toggles…
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
82
votes
22 answers

Check that a input to UITextField is numeric only

How do I validate the string input to a UITextField? I want to check that the string is numeric, including decimal points.
g.revolution
  • 11,962
  • 23
  • 81
  • 107
80
votes
8 answers

Indent the text in a UITextField

My question is as simple as the title, but here's a little more: I have a UITextField, on which I've set the background image. The problem is that the text hugs so closely to it's edge, which is also the edge of the image. I want my text field to…
Dyldo42
  • 2,358
  • 2
  • 22
  • 26
80
votes
12 answers

Programmatically Select all text in UITextField

How can I programmatically select all text in UITextField?
Mirko
  • 2,231
  • 2
  • 21
  • 17
80
votes
30 answers

Formatting a UITextField for credit card input like (xxxx xxxx xxxx xxxx)

I want to format a UITextField for entering a credit card number into such that it only allows digits to be entered and automatically inserts spaces so that the number is formatted like so: XXXX XXXX XXXX XXXX How can I do this?
Can Aksoy
  • 1,322
  • 1
  • 12
  • 18
77
votes
9 answers

How can I add a toolbar above the keyboard?

I have created a UIToolBar programmatically and added a UITextField on it. Now, I need that toolbar to be above the keyboard when I click in another text field. UIToolbar *toolBar=[[UIToolbar alloc]initWithFrame:CGRectMake(0,400,…
Sushil Sharma
  • 945
  • 1
  • 7
  • 9
76
votes
9 answers

Disabling user input for UITextfield in swift

pretty trivial question, I know. But I can not find anything online. I need to disable the user from being able to edit the text inside of a text field. So that when the click on the text, a keyboard doesn't show up. Any ideas? A programmatic…
Matt Spoon
  • 2,760
  • 5
  • 25
  • 41
76
votes
13 answers

Change of UITextField placeholder color

How to dynamically change placeholder color of the UITextField? This is always the same system color. No option in xib editor.
theWalker
  • 2,022
  • 2
  • 18
  • 27
73
votes
2 answers

resignFirstResponder vs. endEditing for Keyboard Dismissal

In Swift, both [someTextField].resignFirstResponder() and self.view.endEditing(true) accomplish the same task - hiding the keyboard from the user's view and de-focusing whatever text field was using it. I understand that the former is specific to a…
curiouslychris
  • 857
  • 1
  • 6
  • 9
73
votes
11 answers

Cursor not showing up in UITextView

Can anyone think of a reason that the blinking cursor would not show up in a UITextView? I have a custom control that is just a subclass of UIView and it has a UITextView in it, but the cursor doesn't appear when it gets focus. The keyboard appears,…
SeanT
  • 1,741
  • 1
  • 16
  • 24
72
votes
13 answers

What's the default color for placeholder text in UITextField?

Does anyone know what color a UITextField's placeholder text is, by default? I'm trying to set a UITextView's text to the same color. I've read elsewhere that it is UIColor.lightGrayColor() but it is actually a little lighter.
pterry26
  • 1,230
  • 1
  • 10
  • 20
71
votes
11 answers

Shake Animation for UITextField/UIView in Swift

I am trying to figure out how to make the text Field shake on button press when the user leaves the text field blank. I currently have the following code working: if self.subTotalAmountData.text == "" { let alertController =…
Joe
  • 827
  • 2
  • 9
  • 13
70
votes
8 answers

Disable auto correction of UITextField

When I try to edit texts in my iPhone application (UITextfield), it auto-corrects my input. Could you let me know how can I disable this?
ebaccount
  • 5,051
  • 11
  • 43
  • 47
69
votes
10 answers

First letter in UiTextField lowercase

How do you make it so that when you start typing on the keyboard after youve clicked on a UITextfield the first letter isn't a capital automatically?
daihovey
  • 3,485
  • 13
  • 66
  • 110