Mickey Mouse
Mickey Mouse

Reputation: 1771

New UITableViewCell not calling subview drawRect()

I am having this problem for the past two days and I'm trying to get my head around it with no good result.

I have a UITableView with custom UITableViewCell. Inside the UITableViewCell I have a custom UIView that I subclassed and drawing it by calling its own drawRect.

The drawing for reused cells has no issues and the cell is calling its own drawRect and the custom subview is calling its own drawRect as well.

The problem arises when a new cell is dequeued, the custom subview drawRect is not called at all leaving that view empty (non visible)

What I did:

That's the only thing I thought of and was obvious to try.

Is there a way to force drawing for the subviews for new UItableViewCell?

Upvotes: 1

Views: 752

Answers (2)

Mickey Mouse
Mickey Mouse

Reputation: 1771

I managed to solve the issue and force the redrawing of the subview of a custom cell by implementing heightForRowAtIndexPath regardless of the iOS version (>=7)

Apparently iOS redraw the cell after the height is being calculated.

Upvotes: 0

Pablo A.
Pablo A.

Reputation: 2052

Have you tried calling [cell setNeedsDisplay] but on the main thread?

Upvotes: 2

Related Questions