3

我正在使用 ICarousel 制作我的电子相册。当您滑动相册时,ICarousel 的默认设置是它会移动一段距离。我需要的是只为一张图片滑动一次。我发现 ICarousel 不是基于 ScrollView 的,所以我不知道如何实现我的目的,有人知道吗?

4

5 回答 5

6

使用最新版本的 iCarousel 更新了答案:

iCarousel 现在通过设置 pagingEnabled=YES 支持单页滑动。

于 2015-07-06T17:01:25.777 回答
5

我建议关闭本机滚动并附加一个使用scrollByNumberofItems方法的 PanGestureRecognizer。

[iCarousel setScrollEnabled:NO];

然后在你的gestureRecognizer里面:

[iCarousel scrollByNumberOfItems:1 duration:0.25];

我自己试过这个,效果很好。

于 2012-05-17T18:49:31.053 回答
0

看来您必须使用由同一作者实现的另一个名为 SwipeView 的库。

发现问题here。 https://github.com/nicklockwood/iCarousel/issues/247

于 2012-12-04T13:50:49.837 回答
0

我通过设置实现了 iCarouselTypeCoverFlow 类型:

//In ViewController.m
self.carousel.pagingEnabled = YES;


//In iCarousel.m change for smooth animation
-(void)scrollByOffset:(CGFloat)offset duration:(NSTimeInterbal)duration{
    if (duration > 0.0)
    {
        _decelerating = NO;
        _scrolling = YES;
        _startTime = CACurrentMediaTime();
        _startOffset = _scrollOffset;
//        _scrollDuration = duration;
// set constant duration instead
        _scrollDuration = 1.0;
        _endOffset = _startOffset + offset;
        if (!_wrapEnabled)
        {
            _endOffset = [self clampedOffset:_endOffset];
        }
        [_delegate carouselWillBeginScrollingAnimation:self];
        [self startAnimation];
    }
    else
    {
        self.scrollOffset += offset;
    }
}
于 2016-09-09T13:50:48.620 回答
0

修改 iCarousel 源代码 iCarousel.m 文件可以做到这一点!

- (void)didPan:(UIPanGestureRecognizer *)panGesture {

 ......

     case UIGestureRecognizerStateChanged: {
            CGFloat translation = _vertical? [panGesture translationInView:self].y: [panGesture translationInView:self].x;

            translation = translation * 0.35; // Add This line to change the really translation.

            ......
     }
}

那解决了我的问题,希望能帮到你!</p>

于 2017-07-03T06:58:39.863 回答