我想實現這樣的iCarousel滾動不順暢
我有一個包含一個數組:
- 圖片名稱
- 圖片聲音
- 圖片名稱正文
我已經完成了幾乎所有的事情,但滾動並不順利。 我正在使用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
任何幫助,將不勝感激。謝謝。
所有圖像都存儲在僅有的資產文件夾中。它也會有用嗎? –
我不確定。我一直使用它與網絡。 –