In my application, I add a UISearchBar .
My intention is to enable the UISearch "X Button" panel (remove the uitextfield button) so that it is always visible.
I tried using the following code below to try to make the "X Button" always visible. However, this does not work. If I set tf.clearButtonMode = UITextFieldViewModeNever , the clear button in uitextfield is not displayed. I'm not sure what's wrong?
I really appreciate if anyone helps here. Why is this not working?
Code (not working)
for (UIView* v in searchBar.subviews) { if ( [v isKindOfClass: [UITextField class]] ) { UITextField *tf = (UITextField *)v; tf.delegate = self; tf.clearButtonMode = UITextFieldViewModeAlways; break; } }
Goal:
I want to always show the clear button if the length of the text is 0
- i.e. if I do not enter any text.
banu Aug 13 '13 at 11:28 2013-08-13 11:28
source share