itenyh
itenyh

Reputation: 1939

How to set ICarousel to slide one time for one one image

I am using ICarousel to make my Electronic Album. When you slide the album , the default setting by ICarousel is that it will move to some distance. What I need is slide one time for one one image only. I found ICarousel is not based on ScrollView , So I can not figure out how to achieve my purpose, is someone who know about it?

Upvotes: 3

Views: 3101

Answers (5)

Beyond Chao
Beyond Chao

Reputation: 115

Modify iCarousel source code iCarousel.m file may do this!

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

            ......
     }
}

That solve my problem,Hope to help you!

Upvotes: 0

blaszku
blaszku

Reputation: 299

I achieved that for type iCarouselTypeCoverFlow 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;
    }
}

Upvotes: 0

Vincent NOCK
Vincent NOCK

Reputation: 205

Updated answer with the more recent versions of iCarousel :

iCarousel now supports single-page swiping by setting pagingEnabled=YES.

Upvotes: 6

Nimit Pattanasri
Nimit Pattanasri

Reputation: 1602

It seems that you have to use another library called SwipeView, implemented by the same author.

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

Upvotes: 0

MobileVet
MobileVet

Reputation: 2958

I would recommend turning off the native scrolling and attaching a PanGestureRecognizer that utilizes the scrollByNumberofItems method.

[iCarousel setScrollEnabled:NO];

Then inside your gestureRecognizer:

[iCarousel scrollByNumberOfItems:1 duration:0.25];

I tried this myself and it worked great.

Upvotes: 5

Related Questions