Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 215
dizy Avatar asked Aug 23 '09 04:08

dizy


1 Answers

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).

like image 53
ryyst Avatar answered Oct 10 '22 00:10

ryyst