Reputation: 393
This has been annoying me for the last hour. I have a UITableView with rows of custom cells. Nothing fancy, just a UITextField for the label and a UITextField for editing. However, there's one row which has the second UITextField's editing disabled and an accessory because pressing that brings up a date picker. The second UITextField in that cell has a placeholder set that says "Select date". When the user selects the date from the picker, that text field gets updated. The update works, but the text color is the same gray as the placeholder's text.
Code:
if(selectedDate == nil)
cell.cellTextField.placeholder = @"Select date";
else
{
cell.cellTextField.text = selectedDate;
}
I can't figure out how to get the UITextField's color to be black. If you scroll that row below the bottom of the view and bring it back, THEN it's black.
I tried setting UIColor to black. No good, and not necessary since the color is correct after scrolling.
I also tried setNeedsDisplay. That didn't work either.
Everything I tried from the docs doesn't work, and yet I can't figure out why iOS is setting the color of the .text to the same color as the .placeholder
Any ideas?
Upvotes: 0
Views: 4801
Reputation: 311
Your description of scrolling off screen then back on implies the following might work:
Try:
[tableView reloadData];
after you have updated the text in your tableView cell (presumably right after the picker has notified you of the pick).
Upvotes: 0