views:

777

answers:

1

Same as http://stackoverflow.com/questions/320078/adding-the-clear-button-to-an-iphone-uitextfield but that one is old. I tried

myUITextField.clearButtonMode = UITextFieldViewModeWhileEditing;

but nothing is happening. What could be preventing it?

+1  A: 

In cellForRowAtIndex, the fix looks like this in my case:

cell = [tableView dequeueReusableCellWithIdentifier:@"CellNameIdentifier"];
 if (cell == nil) {
  [[NSBundle mainBundle] loadNibNamed:@"CellName" owner:self options:nil];
  cell = cellName;
  [cellName setAccessoryType:UITableViewCellAccessoryNone];
        //textfield in inside cellName
  textfield.clearButtonMode = UITextFieldViewModeWhileEditing;
 }
4thSpace