1

I'm using iCarousel to have a scroll of images. THe code is:

- (CATransform3D)carousel:(iCarousel *)_carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform 
{
    CGFloat count = 5; 
    CGFloat spacing = 0.9f; 
    CGFloat arc = M_PI * 0.3f; 
    CGFloat radius = fmaxf(140.0 * spacing / 2.0f, 140.0 * spacing / 2.0f / tanf(arc/2.0f/count));
    CGFloat angle = offset / count * arc;
    radius = -radius;
    angle = -angle;
    transform = CATransform3DTranslate(transform, radius * sin(angle),radius * cos(angle) - radius, 0.0f);                    
    return transform;                                                    
 }

But when I scroll the images there is an ugly effect, the transition is not smooth and the images comes out in a jerky way, but I'd like to come out smootly. Can you help me? Thanks.

Edit: The problem is that when I scroll the images the transition is not smooth and the images comes out in front of the images on the back with a detachment from the other images. Pratically, the images comes in front of the others only when the scrolling did end and this causes a bad effect.

4

1 回答 1

4

我们在上一次实施 iCarousel 时遇到了类似的问题。以下是我们修复它的方法:

- (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value {

    if (option == iCarouselOptionSpacing) {
    return value;// * 1.05f;
    } else if(option == iCarouselOptionWrap) {
    return NO;
    } else if(option == iCarouselOptionVisibleItems) {
    return 3;
    }
    return value;
}

具体来说,您可能需要的是最后一个 else if 语句,我们在其中指定可见项目的数量。它默认为 1,这意味着当您滑动浏览新图像时,会以生涩的方式出现。通过指定 3,您可以保证最近的项目、当前项目和下一个项目始终加载到内存中,因此它们之间的滚动始终是平滑的。如果这不能解决您的问题,请将数字 3 增加到任何可行的值。

另外,不要忘记将 iCarousel 的委托设置为 self。

祝你好运。

于 2013-10-29T15:22:04.847 回答