3

I need to never display the clear button on a specific text field. in IB I've set the clear button as 'Never Appears'. However, once the user inputs even 1 character into the text field, the clear button shows up. These text fields are pretty short (due to spacing) and the clear button covers the written text, which looks terrible.

I need to do away with the clear button all together but setting it as 'Never Appears' still makes it appear.

jszumski
  • 7,430
  • 11
  • 40
  • 53
JMD
  • 1,540
  • 2
  • 24
  • 56
  • Have you tried doing it in code, there may be a bug with IB. `self.myTextField.clearButtonMode = UITextFieldViewModeNever;` – max_ Feb 21 '13 at 14:48
  • also check if you've made connection between textfield and uielement in IB – alex Feb 21 '13 at 14:52
  • there is definitely a connection because text and everything appears fine, as well as the keyboard etc. I'll try it programmatically and see what happens. – JMD Feb 21 '13 at 14:54
  • adding it programmatically had no change – JMD Feb 21 '13 at 15:04

2 Answers2

3
self.myTextField.clearButtonMode = UITextFieldViewModeNever;

Should work to make it never appear.

rdurand
  • 7,342
  • 3
  • 39
  • 72
Naresh
  • 433
  • 2
  • 15
0

Are you sure you didn't set it to "Appears while editing" somewhere by mistake? The default value for the clearButtonMode property is UITextFieldViewModeNever.

From the documentation :

clearButtonMode

Controls when the standard clear button appears in the text field.

@property(nonatomic) UITextFieldViewMode clearButtonMode

Discussion

The standard clear button is displayed at the right side of the text field as a way for the user to remove text quickly. This button appears automatically based on the value set for this property.

The default value for this property is UITextFieldViewModeNever.

rdurand
  • 7,342
  • 3
  • 39
  • 72
CharlieReed
  • 126
  • 1
  • 6