iCarousel滚动不顺畅

问题描述:

我想实现这样的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://*.com/questions/34504659/ios-icarousel-view-scrolling iCarousel auto scrolling not appearing smoothly

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

如果你的数据很重。我建议你使用https://github.com/rs/SDWebImage作为缓存图像。它会使它更平滑,更快速。

+0

所有图像都存储在仅有的资产文件夹中。它也会有用吗? –

+0

我不确定。我一直使用它与网络。 –

设置pagingEnabledfalse

_carousel.pagingEnabled = YES;