Iphone – How to refresh UITableViewCell

cocoa-touchiphoneuitableview

I have a UITableView with a custom UITableViewCell. In cellForRowAtIndexPath, I assign a font to a label in every cell, since the user can change font size at any time. To change font size, the user clicks a button below the tableview, which dislays another view with settings. Once they have chosen a font size and click done, that view goes away and the tableview displays again. I display one cell per viewing area. So the user doesn't see the font change until he scrolls to the next cell. The current cell is the one I'd like to update.

I've tried reloadData from the settings screen but that didn't work. The tableview is a UITableViewController but viewWillAppear never fires once the settings screen goes away. I've tried making the custom cell a property of the tableview so it can be accessed from the settings view, then called setNeedsDisplay and setNeedsLayout. Those didn't work either. Any suggestions?

Best Answer

In your custom UITableViewCell, call [self setNeedsLayout]; and it should repaint your cell at the next loop. I use it for asynchronous image loading since I'm pulling the image from the Web and it works swell.