JeffN
JeffN

Reputation: 1605

Animating a view inside a uitableviewcell

I have nested tableviews so that I can have a sideways scrolling tableview in each of my tableview's cells. I want to add an animation to the top row, that basically moves a view back and forth. It is working, kind of:

    - (UITableViewCell *)tableView:(UITableView *)tableView willDisplayCell: (BannerCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0){
        [UIView animateWithDuration:3
                         animations:^{
                             [UIView setAnimationRepeatCount: 100];
                             cell.handView.frame = CGRectMake(cell.handView.frame.origin.x-100, cell.handView.frame.origin.y, 32, 32);
                             cell.handView.alpha = 0.0f;

                         }
                         completion:^(BOOL finished){

                         }];
    }
    else cell.handView.hidden = YES;

    return cell;

}

This is working except on the first time my tableview loads, the view that I want animating doesn't even show up, when I scroll to a new cell and back to the first cell then it shows up an animates fine. Not sure why it wouldn't run as expected on the first load.

Upvotes: 2

Views: 1227

Answers (1)

puru020
puru020

Reputation: 818

Is this delegate method actually being called? Because the actual delegate method that does this has the following signature:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

Your method is returning a UITableViewCell object. I don't seem to find a delgate method like this.

Upvotes: 3

Related Questions