iCarousel滚动不顺畅

时间:2016-08-18 06:16:05

标签: ios objective-c icarousel

我正在努力实现这样的目标

enter image description here

我有一个包含以下内容的数组:

  • 图片名称
  • 图像声音
  • 图片名称文字

我几乎已经实现了所有功能,但滚动仍然不顺畅。 我正在使用xib创建整体视图并将其加载到iCarousel视图中。

以下是我的代码的一些部分:

在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;

在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;
}

那么,如何使滚动平滑以及如何在交换时禁用反弹

_carousel.bounces = NO;

没有任何影响。

我已经提到的链接:

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

任何帮助将不胜感激。谢谢。

3 个答案:

答案 0 :(得分:0)

如果您的数据很重。我建议你使用https://github.com/rs/SDWebImage缓存图像。它会让它更顺畅,更快。

答案 1 :(得分:0)

pagingEnabled设为false

_carousel.pagingEnabled = YES;

答案 2 :(得分:0)

iCarousel的滚动平滑

viewIcaroseal.isPagingEnabled = true
viewIcaroseal.bounces = false