I have a problem reloading a custom UIView
(SBBarChart
) inside of a table cell. I don't use autolayout because it was too difficult to adjust it will all components of the cell which may be there or not. I manually calculate each time the rectangles and that works.
In respect to the rotation, I have tried implementing in the table view controller the willRotateToInterfaceOrientation
method with [self.tableView reloadData]
inside. This generates the cells again after rotation. Fine.
Inside of the cell class, I invoke [self.barChart setNeedsDisplay]
to ensure that the subviews of the chart will be reloaded, which works.
Now the problem. Initially, portrait view opens and loads correctly. When I rotate to landscape, that works as well. When I rotate back to portrait, the length of the bar is calculated correctly but still displayed as it was in landscape. So the new rectangle for the bar has the right measures but the bar is displayed too long and partly outside of the screen.
A label with the same measures for the frame is displayed (and centered) correctly, so it should be a problem of the bar view reloading.
What am I doing wrong?