EDIT: I originally asked this question in regards to general view resizing, but I realize now that it's something much more specific to tableViews.
Say that a tableView originally has a frame of (0 0, 320 460), i.e., it fills an entire iPhone screen. In order to resize the tableView's height and animate the resize, I map the following code to a button:
[UIView beginAnimations:@"Animation" context:nil];
[UIView setAnimationDuration:3];
CGRect rect = self.table.bounds;
rect.size = CGSizeMake(320, 200);
self.table.bounds = rect;
self.table.center = CGPointMake(160, 100);
[UIView commitAnimations];
This code will animate the table's height down, BUT...before any animation happens, the table will clip off all of the table cells that won't fit in the new bounds. So, given a tableView that originally fits 10 rows, the animation code above will cause this sequence of events:
- The tableView removes the bottom 5 rows immediately. Note that it only removes the rows - the tableView's background still extends to the bottom.
- The tableView animates the height change for the rest of the table as expected.
This is not the behavior I am looking for. Instead of clipping the bottom 5 rows immediately, the tableView should keep its rows in place while the bottom edge of the table just animates upwards.
Based on the behavior I'm seeing, it seems that the tableView is getting some sort of message to refresh its rows immediately after it finds out that its bounds is going to change. Can someone shed some light on this behavior and how I could avoid it?