UITableView frame height animation glitch

UITableView frame height animation glitch

If I attempt to animate the frame height of a tableView (ex: height -= 200), the cells that appear in the last 200px disappear suddenly before the smooth animation of the frame completes.

To make sure that it's nothing else I'm doing, I created a new View-Based application. In the main viewController I create my own tableview with enough pseudo rows to fill the entire screen. And on selection of a row I do a simple height animation.

most relevant code:

 - (void)viewDidLoad {     [super viewDidLoad];     self.myTable = [[[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)] autorelease];     myTable.delegate = self;     myTable.dataSource = self;     [self.view addSubview:myTable]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {     CGRect frame = self.myTable.frame;     frame.size.height = 200;     [UIView beginAnimations:nil context:nil];     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];     [UIView setAnimationDelay:.5f];     [UIView setAnimationDuration:0.5f];     self.myTable.frame = frame;     [UIView commitAnimations]; }  

Does anyone know why this is happening, or what a fix/workaround may be?

Any suggests are really appreciated. TIA!

How do I find out if I need to retain or assign an property?


Can I use a mono library from Objective-C (on the iPhone)?
I'm not sure I had exactly the same problem, but using [UIView setAnimationBeginsFromCurrentState:YES]; solved (parts of) the glitches (my table view slid around crazily when animating a frame height change)..
Which are the Top Level Objects I need to create Outlests for in the File's Owner of my Nib, so that I have less memory problems?

iPhone Data

Why don't I have to release these objects?


jQuery not loading on the iPhone
Same problem here as well.

Asyncsocket VS NSstream
This is what I'm doing and the origin animates smoothly, but the size changes immediately...

NSOuputStream writing multiple times
    [UIView beginAnimations:@"HideTabbar" context:nil];     [UIView setAnimationDuration:.3];         self.tableView.frame = CGRectMake(0.0, 44.0, 320, 366);     [UIView commitAnimations]; 
UPDATE: Try adding this before the animation:.
self.tableView.autoresizingMask = UIViewAutoresizingNone; 


For anyone hitting this question & answer in the future, here's how to use @ryyst's answer in UIView's block based animations introduced in iOS 4..
    [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{             // change frame etc here     } completion:^(BOOL finished) {             // any clean up here     }]; 


This is an old question and there are already a couple suggestions for a workaround, but I thought I'd add mine.. I ended up animating the contentInset and scrollIndicatorInsets properties, which provides the illusion that the table itself is being resized..


I found your question while seeking the proper method to resize a tableView.

I think your problem is in your animation you've specified "UIView" instead of UITableView.

I was unable to duplicate your problem using either UIView or UITableView, but I'm using SDK 3.1 and it might be a bug that has been fixed since your post.

I'm not sure, but I hope this helps!.


I have exactly the same problem.

I imagine that tableviews have a special behavior on "setFrame:", it seems that the tableview remove the cells that won't be visible with the new frame.. In case of an animation, the cells won't be visible only at the end of the animation, but it seems that tableviews don't care.. If someone have a better theory, I'd be glad to hear it !.


It's an old question but this might help someone in the future;. I solved a similar problem by embedding the tableview in a UIView, and resizing the UIView instead of tableview.

I set the tableview's height to a large value and also "clip subviews" property on the UIView.

I resize the UIView proportional to tableview's contentSize.

Its not a good solution but it worked for my purposes..

76 out of 100 based on 66 user ratings 1066 reviews