我正在使用iCarousel
来显示用户点击的图像,并动态重新加载到轮播中。整个设置与iCarouselOptionVisibleItems
的默认值完美配合,但当图像总数超过8时,图像开始向上扩展。
为了尝试解决这个问题,我将iCarouselOptionVisibleItems的数量增加到25并暂时解决了问题,但我知道这不是最好的解决方案,因为图像在数量超过25后仍然可以缩放。有什么我想念的吗从我缺少的文件?
这是我的icarousel屏幕的代码
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.carousel.delegate = self;
self.carousel.dataSource = self;
_carousel.type = iCarouselTypeCoverFlow2;
}
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
//return the total number of items in the carousel
return [images count];
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
//create new view if no view is available for recycling
if (view == nil)
{
//don't do anything specific to the index within
//this `if (view == nil) {...}` statement because the view will be
//recycled and used with other index values later
view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)];
view.contentMode = UIViewContentModeScaleAspectFit;
((UIImageView *)view).image = [UIImage imageWithContentsOfFile:[images objectAtIndex:index]];
}
else
{
//get a reference to the label in the recycled view
view.contentMode = UIViewContentModeScaleAspectFit;
view = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[images objectAtIndex:index]]];
}
return view;
}
- (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
if (option == iCarouselOptionSpacing)
{
return value * 1.1f;
}
else if (option == iCarouselOptionVisibleItems)
{
return 25;
}
return value;
}