ios - UITableView WillDisplayCell 方法在特定时间后调用?

标签 ios objective-c iphone uitableview

我正在尝试将动画放在 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 会快速显示。提前致谢。

最佳答案

我按照@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) {
    }];
});

关于ios - UITableView WillDisplayCell 方法在特定时间后调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45790433/

相关文章:

iPhone:在运行时下载 zip 并在主包子目录中解压

ios - 如何使用自动布局防止 UIButton 超过其父 UIView 的宽度

iphone - 将新共享者添加到相机胶卷

c++ - 如何将C++代码合并到Objective-C项目中?

objective-c - dealloc 在 vi​​ewDidUnload 之后会被调用吗?

iphone - 如何在 iPhone 上使用 Activity 指示器 View ?

ios - 错误 : linker command failed with exit code 1 (use -v to see invocation) xcode error?

iOS:下载 .TXT 文件给出奇怪的结果

objective-c - 在 Cocoa 中添加一个新窗口

ios - iOS 中的 UIPickerView 中的 UITableView