UITableViewCell动画打破了UITableView触摸检测和滚动

时间:2014-10-08 16:30:09

标签: ios objective-c iphone uitableview catransform3d

第一次出现时,我试图在显示新的UITableViewCells时实现类似于谷歌+动画。

这就是我正在做的事情:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if([[self serverFetchControllerForTableView:tableView] hasDataAtIndexPath:indexPath])
    {
        if (![[self shownIndexesForTableView:tableView] containsObject:indexPath]) {
            [[self shownIndexesForTableView:tableView] addObject:indexPath];

            UIView* view = [cell contentView];
            view.layer.transform = self.initialTransformation;
            view.layer.opacity = 0.0;

            [UIView animateWithDuration:ANIMATION_CELL_APPEARANCE_TIME animations:^{
                view.layer.transform = CATransform3DIdentity;
                view.layer.opacity = 1;
            }];
        }
    }
}

//initial transformation looks like that
CGFloat rotationAngleRadians = ANIMATION_CELL_APPEARANCE_ANGLE_DEG * (M_PI/180);
CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DRotate(transform, rotationAngleRadians, 1.0, 0.0, 1.0);
transform = CATransform3DTranslate(transform, ANIMATION_CELL_APPEARANCE_X, ANIMATION_CELL_APPEARANCE_Y, 0.0);
self.initialTransformation = transform;

一切都在视觉效果方面有效,但是当这些单元格出现时,我失去了对UITableView滚动的完全控制 - 我无法触摸单元格,停止滚动或选择其中任何一个,直到动画完成。

有没有人有任何建议我可以做些什么来解决这个问题呢?

同样的问题可以在这里找到: http://www.raywenderlich.com/49311/advanced-table-view-animations-tutorial-drop-in-cards

尝试在TipInCellAnimator中将时间设置为3.0秒,任何3.0控制都会完全丢失。

1 个答案:

答案 0 :(得分:2)

这是使用animateWithDuration...方法之一的动画的正常行为。如果您想在动画期间进行用户交互,请尝试使用 animateWithDuration:delay:options:animations:completion:并传递UIViewAnimationOptionAllowUserInteraction作为选项。我不知道你的动画可能会做些什么,但它应该允许用户互动。

相关问题