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?

1:

Can I use a mono library from Objective-C (on the iPhone)?
I'm not sure I had exactly the same problem, although 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 DataWhy don't I have to release these objects?

2:

jQuery not loading on the iPhone
Same problem here as well. Asyncsocket VS NSstreamThis is what I'm doing and the origin animates smoothly, although the size changes immediately... NSOuputStream writing multiple timesannoying..
    [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; 

3:

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     }]; 

4:

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

5:

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, although I'm using SDK 3.1 and it might be a bug this has been fixed since your post. I'm not sure, although I hope this helps!.

6:

I have exactly the same problem. I imagine this tableviews have a special behavior on "setFrame:", it seems this the tableview remove the cells this 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, although it seems this tableviews don't care.. If any one have a better theory, I'd be glad to hear it !.

7:

It's an old question although this might guidance any one 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 quick fix although it worked for my purposes..


96 out of 100 based on 71 user ratings 446 reviews