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
1733
votes
95 answers

How can I make a UITextField move up when the keyboard is present - on starting to edit?

With the iOS SDK: I have a UIView with UITextFields that bring up a keyboard. I need it to be able to: Allow scrolling of the contents of the UIScrollView to see the other text fields once the keyboard is brought up Automatically "jump" (by…
philfreo
  • 36,787
  • 25
  • 119
  • 140
579
votes
32 answers

iPhone UITextField - Change placeholder text color

I'd like to change the color of the placeholder text I set in my UITextField controls, to make it black. I'd prefer to do this without using normal text as the placeholder and having to override all the methods to imitate the behaviour of a…
adam
  • 21,709
  • 20
  • 83
  • 117
482
votes
45 answers

Set the maximum character length of a UITextField

How can I set the maximum amount of characters in a UITextField on the iPhone SDK when I load up a UIView?
Domness
  • 7,477
  • 8
  • 38
  • 49
476
votes
38 answers

iOS - Dismiss keyboard when touching outside of UITextField

I'm wondering how to make the keyboard disappear when the user touches outside of a UITextField.
jonepatr
  • 7,499
  • 7
  • 27
  • 53
424
votes
31 answers

Text inset for UITextField?

I would like to inset the text of a UITextField. Is this possible?
RunLoop
  • 19,113
  • 21
  • 89
  • 146
408
votes
32 answers

Set padding for UITextField with UITextBorderStyleNone

I wanted to use a custom background for my UITextFields. This works fine except for the fact that I have to use UITextBorderStyleNone to make it look pretty. This forces the text to stick to the left without any padding. Can I set a padding manually…
Sebastian Wramba
  • 9,837
  • 8
  • 36
  • 56
368
votes
30 answers

Converting String to Int with Swift

The application basically calculates acceleration by inputting Initial and final velocity and time and then use a formula to calculate acceleration. However, since the values in the text boxes are string, I am unable to convert them to…
Marwan Qasem
  • 3,691
  • 2
  • 9
  • 4
326
votes
19 answers

How do I check when a UITextField changes?

I am trying to check when a text field changes, equivalent too the function used for textView - textViewDidChange so far I have done this: func textFieldDidBeginEditing(textField: UITextField) { if self.status.text == "" &&…
user4184036
268
votes
11 answers

How to create a multiline UITextfield?

I am developing an application where user has to write some information. For this purpose I need a UITextField which is multi-line (in general UITextField is a single line). As I'm Googling I find a answer of using UITextView instead of UITextfield…
raaz
  • 11,942
  • 21
  • 59
  • 81
236
votes
20 answers

How to hide keyboard in swift on pressing return key?

I am using UITextfied while clicking on textfied keyboard appear but when i pressed the return key, keyboard is not disappearing. I used the following code: func textFieldShouldReturn(textField: UITextField!) -> Bool // called when 'return' key…
Ashwinkumar Mangrulkar
  • 2,677
  • 3
  • 12
  • 17
234
votes
16 answers

Change UITextField and UITextView Cursor / Caret Color

I'm wondering about changing the color of the cursor / caret in a UITextField (And UITextView if its the same answer) in iOS. I've seen answers for OSX development, but nothing for iOS. Is this even possible?
RileyE
  • 10,308
  • 12
  • 60
  • 103
227
votes
37 answers

Move textfield when keyboard appears swift

I'm using Swift for programing with iOS and I'm using this code to move the UITextField, but it does not work. I call the function keyboardWillShow correctly, but the textfield doesn't move. I'm using autolayout. override func viewDidLoad() { …
Pedro Manfredi
  • 3,628
  • 5
  • 17
  • 20
215
votes
13 answers

iPad keyboard will not dismiss if modal ViewController presentation style is UIModalPresentationFormSheet

Note: See accepted answer (not top voted one) for solution as of iOS 4.3. This question is about a behavior discovered in the iPad keyboard, where it refuses to be dismissed if shown in a modal dialog with a navigation controller. Basically, if I…
Kalle
  • 12,846
  • 7
  • 58
  • 74
185
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
  • 44,308
  • 19
  • 90
  • 118
183
votes
10 answers

Adding the "Clear" Button to an iPhone UITextField

How do you add that little "X" button on the right side of a UITextField that clears the text? I can't find an attribute for adding this sub-control in Interface Builder in the iPhone OS 2.2 SDK. Note: In Xcode 4.x and later (iPhone 3.0 SDK and…
Kristopher Johnson
  • 76,675
  • 54
  • 235
  • 299
1
2 3
99 100