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
191
votes
22 answers

How do you dismiss the keyboard when editing a UITextField

I know that I need to tell my UITextField to resign first responder when I want to dismis the keyboard, but I'm not sure how to know when the user has pressed the "Done" key on the keyboard. Is there a notification I can watch for?
kubi
  • 48,104
  • 19
  • 94
  • 118
182
votes
12 answers

Programmatically change UITextField Keyboard type

Is it possible to programmatically change the keyboard type of a uitextfield so that something like this would be possible: if(user is prompted for numeric input only) [textField setKeyboardType: @"Number Pad"]; if(user is prompted for…
eric.mitchell
  • 8,817
  • 12
  • 54
  • 92
180
votes
12 answers

Having a UITextField in a UITableViewCell

I'm trying to do that for a couple of days now, and after reading tons of messages of people trying to do that too, I'm still unable to have a fully working UITextField in some of my UITableViewCells, just like in this example: Either I have the…
Mathieu
  • 1,984
  • 4
  • 13
  • 16
175
votes
7 answers

Super slow lag/delay on initial keyboard animation of UITextField

It takes roughly 3-4 seconds for the keyboard to pop up after I touch my UITextField. This only occurs on the first time the keyboard pops up since the app launched, afterwards the animation starts instantly. At first I thought it was problem of…
Vadoff
  • 9,219
  • 6
  • 43
  • 39
164
votes
15 answers

Hide the cursor of a UITextField

I am using a UITextField with a UIPickerView for its inputView, so that when the user taps the text field, a picker is summoned for them to select an option from. Nearly everything works, but I have one problem: the cursor still flashes in the text…
emenegro
  • 6,901
  • 10
  • 45
  • 68
160
votes
5 answers

Getting and Setting Cursor Position of UITextField and UITextView in Swift

I've been experimenting with UITextField and how to work with it's cursor position. I've found a number of relation Objective-C answers, as in Getting the cursor position of UITextField in ios Control cursor position in UITextField UITextField get…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
145
votes
5 answers

How do I vertically center UITextField Text?

I am simply instantiating a UITextField and noticing that the text doesn't center vertically. Instead, it is flush with the top of my button, which I find kind of odd since I would expect the default to center it vertically. How can I center it…
Joey
  • 7,537
  • 12
  • 52
  • 104
145
votes
20 answers

Max length UITextField

When I've tried How to you set the maximum number of characters that can be entered into a UITextField using swift?, I saw that if I use all 10 characters, I can't erase the character too. The only thing I can do is to cancel the operation (delete…
giorgionocera
  • 6,428
  • 6
  • 20
  • 17
144
votes
28 answers

Detect backspace in empty UITextField

Is there any way to detect when the Backspace/Delete key is pressed in the iPhone keyboard on a UITextField that is empty? I want to know when Backspace is pressed only if the UITextField is empty. Based on the suggestion from @Alex Reynolds in a…
marcc
  • 12,295
  • 7
  • 49
  • 59
139
votes
9 answers

UITextField border color

I have really great wish to set my own color to UITextField border. But so far I could find out how to change the border line style only. I've used background property to set background color in such way: self.textField.backgroundColor =…
dasha
  • 1,419
  • 2
  • 11
  • 5
133
votes
19 answers

How to set UITextField height?

I am using a UITextField. I want to increase its height but I have not found any property to do this. How can I achieve this?
Arun
  • 3,478
  • 8
  • 33
  • 46
125
votes
21 answers

Swift add icon/image in UITextField

I would like to add icon/image in UITextField. The icon/image should be left to placeholder. I tried this: var imageView = UIImageView(); var image = UIImage(named: "email.png"); imageView.image = image; emailField.leftView = imageView; Thanks.
informatiker
  • 2,769
  • 4
  • 17
  • 13
124
votes
23 answers

Set the maximum character length of a UITextField in Swift

I know there are other topics on this, but I can't seem to find out how to implement it. I'm trying to limit a UITextField to only five characters. Preferably alphanumeric, -, ., and _. I've seen this code: func textField(textField: UITextField,…
ishkur88
  • 1,265
  • 2
  • 9
  • 12
122
votes
7 answers

UITextField auto-capitalization type - iPhone App

Is there a way to set the autocapitalizationType for a UITextField so that the first letter of each word is capitalized by default? This Is An Example Of What I Want
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
122
votes
18 answers

iPhone Keyboard Covers UITextField

I have an app where, in Interface Builder, I set up a UIView that has a text field near the bottom of the view. When I run the app and try to enter text into that field, the keyboard slides up overtop of the field so I can't see what I'm typing…
Cruinh
  • 3,611
  • 4
  • 38
  • 45