How to set iCarousel to glide once for a single image

I use iCarousel to create my electronic album. When you push an album, the default setting for ICarousel is that it moves a certain distance. I need only one slide for one image. I found that iCarousel is not based on ScrollView, so I cannot figure out how to achieve my goal, is it someone who knows about this?

+3
source share
5 answers

I would recommend disabling native scrolling and setting up PanGestureRecognizer, which uses the scrollByNumberofItems method.

[iCarousel setScrollEnabled:NO];

Then inside your Recognizer gesture:

[iCarousel scrollByNumberOfItems:1 duration:0.25];

I tried this myself and it worked perfectly.

+5
source

iCarousel:

iCarousel , pagingEnabled = .

+5

, SwipeView, .

The problem was found here. https://github.com/nicklockwood/iCarousel/issues/247

0
source

I achieved this for the iCarouselTypeCoverFlow type by setting:

//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;
    }
}
0
source

Change iCarousel source code. The iCarousel.m file can do it!

- (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.

            ......
     }
}

This will solve my problem, I hope to help you!

0
source

All Articles