0
votes

I am trying to achieve something like this

enter image description here

I have an array which contains :

  • Image Name
  • Image Sound
  • Image Name Text

I have achieved almost everything, but still the scrolling is not smooth. I am using a xib to create the overall view and loading it inside the iCarousel view.

Here are some parts of my code :

In ViewDidLoad :

//here main view is a view on main storyboard which contains my iCarousel view
    _carousel = [[iCarousel alloc] initWithFrame:self.mainView.bounds];
        _carousel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        _carousel.type = iCarouselTypeLinear;
        _carousel.delegate = self;
        _carousel.pagingEnabled = YES;
        _carousel.backgroundColor = [UIColor clearColor];
        _carousel.dataSource = self;
        _carousel.clipsToBounds = YES;

In viewForItemAtIndex:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{

    CategoryDetailView *view2 = view?:[[[NSBundle mainBundle] loadNibNamed:@"CategoryDetailView" owner:self options:nil]lastObject];
    view2.frame=CGRectMake(0, 0, _mainView.bounds.size.width, _mainView.bounds.size.height);


    UIColor *color=[self getColor:[[Common getUserDefaultsForKey:@"CurrentColor"] stringByAppendingString:@"Color"]];
    [_lblCategory setTextColor:color];
    [view2.btnItem setTitleColor:color forState:UIControlStateNormal];

    // [_btnItemName setBackgroundImage:[UIImage imageNamed:@"medium_btn"] forState:UIControlStateNormal];


    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {


        [_lblCategory setFont:[UIFont fontWithName:[Common getUserDefaultsForKey:@"CurrentFontStyle"] size:30.0]];
        [view2.btnItem.titleLabel setFont:[UIFont fontWithName:[Common getUserDefaultsForKey:@"CurrentFontStyle"] size:30.0]];
    }else{


        [_lblCategory setFont:[UIFont fontWithName:[Common getUserDefaultsForKey:@"CurrentFontStyle"] size:16.0]];
        [view2.btnItem.titleLabel setFont:[UIFont fontWithName:[Common getUserDefaultsForKey:@"CurrentFontStyle"] size:16.0]];
    }

     // here i am attaching data to there respective fields, like image to imageView etc.


    return view2;
}

So, how to make the scrolling smooth and also how to disable the bounce while swapping as

_carousel.bounces = NO;

does not have any effect.

Links I already referred :

iCarousel not scrolling smoothly https://stackguides.com/questions/34504659/ios-icarousel-view-scrolling iCarousel auto scrolling not appearing smoothly

Any help would be appreciated. Thanks.

3

3 Answers

0
votes

If your data is heavy. I suggest you to use https://github.com/rs/SDWebImage for cache image. It'll make it smoother and faster.

0
votes

Set pagingEnabled to false

_carousel.pagingEnabled = YES;
0
votes

The scrolling smooth for iCarousel

viewIcaroseal.isPagingEnabled = true
viewIcaroseal.bounces = false