【问题标题】:UITableView WillDisplayCell Method call after particular time?UITableView WillDisplayCell 方法在特定时间后调用?
【发布时间】:2017-08-21 06:19:41
【问题描述】:

我正在尝试将动画放在 UITableViewCell 上从下到上,这可以正常工作:

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


cell.alpha =0.0;

    UIView *cellContentView = [cell contentView];
    CGFloat rotationAngleDegrees = -30;
    CGFloat rotationAngleRadians = rotationAngleDegrees * (M_PI/180);
    CGPoint offsetPositioning = CGPointMake(0, cell.contentView.frame.size.height*4);
    CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DRotate(transform, rotationAngleRadians, -50.0, 0.0, 1.0);
    transform = CATransform3DTranslate(transform, offsetPositioning.x, offsetPositioning.y, -50.0);
    cellContentView.layer.transform = transform;
    cellContentView.layer.opacity = 0.8;

    [UIView animateWithDuration:3.0 delay:indexPath.row+3 usingSpringWithDamping:0.85 initialSpringVelocity:0.8 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        cellContentView.layer.transform = CATransform3DIdentity;
        cellContentView.layer.opacity = 1;
        cell.alpha=1.0;

    } completion:^(BOOL finished) {

    }];

}

在这里,我想以 2 或 3 秒的间隔一个一个地显示每个单元格。目前 Cell 会快速显示。提前致谢。

【问题讨论】:

  • 更改延迟delay:3
  • 如果我更改它将同时显示所有单元格,而不是一一显示这就是为什么我将 indexPath.row 放在这里
  • 试试这个。在“dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 15.0 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void){ });”中编写 UIView animateDuration 代码
  • @PhaniRaghu 它会随机显示单元格,而不是像 0,1,2 这样的索引...
  • 先告诉我一件事。显示单元格是否需要时间?

标签: ios objective-c iphone uitableview


【解决方案1】:

我通过@PhaniRaghu 给出的想法解决了这个问题,我对他的回答做了一些修改,效果很好。

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, indexPath.row * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
    [UIView animateWithDuration:3.0 
            delay:indexPath.row 
            usingSpringWithDamping:0.85 
            initialSpringVelocity:0.8 
            options:UIViewAnimationOptionCurveEaseInOut 
            animations:^{
                cellContentView.layer.transform = CATransform3DIdentity;
                cellContentView.layer.opacity = 1;
                cell.alpha=1.0;
    } completion:^(BOOL finished) {
    }];
});

【讨论】:

    猜你喜欢
    • 2011-06-04
    • 1970-01-01
    • 1970-01-01
    • 2011-10-06
    • 1970-01-01
    • 2018-07-15
    • 2013-05-15
    • 2014-07-09
    • 2011-03-27
    相关资源
    最近更新 更多