3

I have a tableView. Instead of having multiple subviews in each tableViewCell , i have added one main subview which draws each of the other subviews in its drawRect method. (I have read somewhere that this makes scroll animation look better. Also apple has a sample project CustomTableViewCell).

First , problem is when i changes the orientation of device, then drawRect does not call automatically. And each tableviewcell appears to be stretced. I solved this by using

mainView.contentMode = UIViewContentModeRedraw

This solves the problem. Now when the orientation change is done, drawRect is called automatically .

But during the orientation change, the animation of rotating view still shows each tableview cell stretched. It is a very small thing, but still it is noticeable. Can anyone suggest something on this ?????

Yatin Sarbalia
  • 211
  • 2
  • 9

1 Answers1

0

You can't redraw during animation (not easily, anyway).

Split the table cell into components again and setup autoresizing correctly. The animation will then animate only component positions and it will look fine.

Where did you read drawRect: would make scroll animation better? Did you have some problems with scrolling animation?

Edit: IMHO There is no way how to fix resizing animations and keep the performance increase from using drawRect: instead of subviews.

Sulthan
  • 128,090
  • 22
  • 218
  • 270
  • I understand why it will make the repainting faster, it will skip the layer compositing but it has some flaws. You have found of them. The question is, do you really need to do this? Was your scrolling animation slow? Isn't that a typical case of premature optimization? – Sulthan Mar 29 '12 at 12:00
  • yeah !!! Thats what i want to optimize. Having 10000 rows in table and make scrolling better is better with the stretching problem i have identified. I just want to try if by any way i can solve that too. – Yatin Sarbalia Mar 29 '12 at 12:06
  • Edited the answer. I think that using `drawRect:` is something that is necessary only in extreme cases. In most situations the performance is fine or you can increase it simply by correctly setting properties of the subviews. – Sulthan Mar 29 '12 at 14:01