Monday, 26 August 2013

How to refactor a UITableViewCell configuration code?

How to refactor a UITableViewCell configuration code?

I have a tableview with a single custom table view cell that over time has
resulted to a somewhat convoluted structure and I'm hoping to simplify and
improve it. Basically in the current form, there are images and buttons on
the left and right side of the cell and possibly two different labels in
the middle.
The cells are configured based on the entry they are representing, the
section of table view and the state of the tableview and therefore both
the code in cellForRowAtIndexPath and willDisplayCell has become quite
cluttered. The configuration includes hiding/unhiding of the non-label
subviews and possibly changing the frame of the UILabels.
How would you suggest going about structuring and improving such a code
and when would you start using different custom cell classes?

No comments:

Post a Comment