Ios UICollectionView单元格未选择翻转动画,缺少视图

Ios UICollectionView单元格未选择翻转动画,缺少视图,ios,animation,uicollectionview,Ios,Animation,Uicollectionview,UICollectionView单元格翻转didSelect方法上的动画应翻转,并包含单击的索引单元格的详细信息,如果用户希望转到原始视图,则应能够在单元格上看到。 我正在使用 UICollectionViewCell* cell = [collectionView cellForItemAtIndexPath:indexPath]; [UIView animateWithDuration:1.0 delay:0

UICollectionView单元格翻转didSelect方法上的动画应翻转,并包含单击的索引单元格的详细信息,如果用户希望转到原始视图,则应能够在单元格上看到。 我正在使用

 UICollectionViewCell* cell = [collectionView cellForItemAtIndexPath:indexPath];
    [UIView animateWithDuration:1.0
                          delay:0
                        options:(UIViewAnimationOptionAllowUserInteraction)
                     animations:^
     {

         [UIView transitionFromView:cell.contentView
                             toView:cell.contentView
                           duration:.5
                            options:UIViewAnimationOptionTransitionFlipFromRight
                         completion:nil];
     }
                     completion:^(BOOL finished)
     {

     }
     ];

在你的代码中,动画从视图中删除你的内容并显示到视图中。因此,在集合中,如果内容视图被删除,那么它将如何返回。 因此,不要删除视图,只需将其隐藏

请使用下面的代码

CVCell* cell1 = (CVCell *)[collectionView cellForItemAtIndexPath:indexPath];
[UIView transitionWithView:cell1.contentView
                  duration:5
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{

                    if (cell1.isred) {
                     cell1.isred = NO;
                        cell1.greenview.hidden = NO;
                        cell1.redView.hidden=YES;
                    } else {
                        cell1.isred = YES;
                        cell1.greenview.hidden = YES;
                        cell1.redView.hidden=NO;
                    }

                } completion:nil];
绿色视图是第一个视图,红色视图是第二个视图,添加到单元格上。 现在,当翻转的第一个绿色视图显示,红色视图隐藏,下一次反之亦然

您可以尝试其他动画

    CATransition *animation = [CATransition animation];
    animation.delegate = self;
    animation.duration = 2.6f;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.fillMode = kCAFillModeForwards;
    animation.startProgress = 0.1;
    animation.endProgress = 1.0;
    animation.removedOnCompletion = YES;
    animation.type = @"cube";//---
animation.subtype = (cell1.isred)?kCATransitionFromLeft:kCATransitionFromRight;
[CATransaction setCompletionBlock:^{
                    if (cell1.isred) {
                     cell1.isred = NO;
                        cell1.greenview.hidden = NO;
                        cell1.redView.hidden=YES;
                    } else {
                        cell1.isred = YES;
                        cell1.greenview.hidden = YES;
                        cell1.redView.hidden=NO;
                    }
}];

[cell1.contentView.layer addAnimation:animation forKey:@"Cameraanimation"];

你能在didselect中发布所有代码吗