I just solved my problem. I found three major mistakes in my code.
1) I was using dequeueReusableCellWithIdentifier
after removing controls from cells. This resulted in missing controls and strange behavior. Now I generate each time a new cell from the nib.
2) I was using x
and y
values of controls which I had removed from the cell. I just put the numeric values instead.
3) I was using the frame
for determining the width of the screen. However, the frame does not change. To solve this, I used the following thread: How to get orientation-dependent height and width of the screen?
Now, I don't even need the line [self.barChart setNeedsDisplay]
and I can rotate the device as much as I want, the controls don't shift anymore. :)
I am still not sure that I have to invoke reloadData
for adjusting the layout but I haven't found a better solution.
So, finally it works! Thank you a lot for the help and I hope, this post will help someone else. :)