1

ユーザーがテーブルビューをscreen1からscreen2に表示するようになったときに、各セルをアニメーション化する必要があります。それを行うことは可能ですか、私を助けてください。

前もって感謝します

私はこれを試しました:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell Identifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if(cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell.png"]];
    }

    CATransition *transition = [CATransition animation];
    transition.duration = 1;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = @"cube";
    transition.subtype = kCATransitionFromBottom;
    transition.delegate = self;
    [cell.layer addAnimation:transition forKey:nil];

    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.textLabel.text = [shopList objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0f];
    return cell;
}
4

3 に答える 3

1

willDisplayCell: テーブル デリゲート メソッドでアニメーションを試す

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

if (!isAnimate)
{
    CABasicAnimation *rotationAnimation;

    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"position"];

    rotationAnimation.fromValue=[NSValue valueWithCGPoint:CGPointMake([cell center].x+320, [cell center].y)];
    rotationAnimation.toValue=[NSValue valueWithCGPoint:CGPointMake([cell center].x, [cell center].y)];

    rotationAnimation.duration = 1.0+i;
    rotationAnimation.speed = 3.0;

    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 1.0;
    rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

    [cell.layer addAnimation:rotationAnimation forKey:@"position"];

    i=i+0.5;
}
}
于 2013-08-08T10:26:29.477 に答える
1

このようにしてみて、

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell Identifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if(cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell.png"]];
    }

    [UIView beginAnimations:@"RESIZE_BG" context:NULL];
    [UIView setAnimationDuration:0.5];
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.textLabel.text = [shopList objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0f];
    [UIView commitAnimations];

    return cell;
}
于 2013-05-22T12:20:45.770 に答える
0

これを試して

[tblView insertRowsAtIndexPaths:tempArray withRowAnimation:UITableViewRowAnimationTop];
于 2013-08-08T10:53:45.797 に答える