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:

8328 questions
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,964
  • 4
  • 13
  • 16
177
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,501
  • 12
  • 50
  • 91
172
votes
23 answers

Create space at the beginning of a UITextField

I want to leave a bit of space at the beginning of a UITextField, just like here: Add lefthand margin to UITextField But I don't know how to do that with Swift.
LinusGeffarth
  • 21,607
  • 24
  • 100
  • 152
171
votes
11 answers

Super slow lag/delay on initial keyboard animation of UITextField

Alright, this problem has been driving me nuts. 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…
Vadoff
  • 8,831
  • 6
  • 40
  • 39
157
votes
14 answers

Hide the cursor of an 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,510
  • 9
  • 42
  • 64
144
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,457
  • 12
  • 50
  • 103
136
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,389
  • 2
  • 10
  • 5
134
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,129
  • 7
  • 47
  • 59
132
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,398
  • 8
  • 31
  • 46
130
votes
19 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…
Giorgio Nocera
  • 5,798
  • 6
  • 17
  • 17
127
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
  • 364,799
  • 232
  • 1,155
  • 1,198
121
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,481
  • 4
  • 33
  • 44
117
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
  • 26,751
  • 71
  • 191
  • 310
117
votes
10 answers

Using `textField:shouldChangeCharactersInRange:`, how do I get the text including the current typed character?

I'm using the code below to try and have textField2's text content get updated to match textField1's whenever the user types in textField1. - (BOOL) textField: (UITextField *)theTextField shouldChangeCharactersInRange: (NSRange)range…
user265961
  • 1,323
  • 3
  • 10
  • 10
116
votes
14 answers

Blank space at top of UITextView in iOS 10

I have UITextView with some text in it. Everything was fine with iOS 6 but now with iOS 7 it leaves the blank space on top and then place the text below the middle of the textview. I didn't set any contentOffSet. Please Help!
Ali Sufyan
  • 2,008
  • 3
  • 15
  • 27