我正在与iCarousel - https://github.com/nicklockwood/iCarousel。不同的宽度为不同的项目 - 在iCarousel
虽然我需要更改不同项目的宽度,但意味着要为不同的项目设置不同的宽度。
不确定如何进行更改,如果您对此有任何经验,请帮助。
另一个问题是如何使它滚动时只滚动1项目。 - 表示只滚动到下一个项目,目前它会继续滚动到下一个项目的下一个...
任何帮助,高度赞赏。
我正在与iCarousel - https://github.com/nicklockwood/iCarousel。不同的宽度为不同的项目 - 在iCarousel
虽然我需要更改不同项目的宽度,但意味着要为不同的项目设置不同的宽度。
不确定如何进行更改,如果您对此有任何经验,请帮助。
另一个问题是如何使它滚动时只滚动1项目。 - 表示只滚动到下一个项目,目前它会继续滚动到下一个项目的下一个...
任何帮助,高度赞赏。
因为当滚动你必须添加gestureRecognizer &禁用转盘的滚动只滚动1项
_myCarousel = [[iCarousel alloc] initWithFrame:CGRectMake(0,0, 310, 100)];
_myCarousel.type = iCarouselTypeCoverFlow2;
_myCarousel.scrollEnabled = NO;
UISwipeGestureRecognizer * swipeleft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeleft:)];
swipeleft.direction = UISwipeGestureRecognizerDirectionLeft;
[_myCarousel addGestureRecognizer:swipeleft];
UISwipeGestureRecognizer * swiperight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swiperight:)];
swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[_myCarousel addGestureRecognizer:swiperight];
_myCarousel.dataSource = self;
_myCarousel.delegate = self;
[myView addSubview:_myCarousel];
swipeleft: & swiperight:将作为
-(void)swipeleft:(UISwipeGestureRecognizer*)gestureRecognizer
{
[_myCarousel scrollByNumberOfItems:1 duration:0.25];
}
-(void)swiperight:(UISwipeGestureRecognizer*)gestureRecognizer
{
[_myCarousel scrollByNumberOfItems:-1 duration:0.25];
}
工作我如预期的那样。 希望这会帮助你..
问题1:
在iCarousel itemWidth财产是只读的,你应该使用转盘:viewForItemAtIndex:reusingView为了这个目的:
@property (nonatomic, readonly) CGFloat itemWidth;
项目在传送带上的显示宽度(只读)。这是 使用carousel:viewForItemAtIndex:reusingView:dataSource方法自动从传递到传送带 的第一个视图导出。 您也可以使用carouselItemWidth:delegate 方法覆盖此值,该方法将改变为轮播项目分配的空间(但 不会调整或缩放项目视图)。
问题2:
使用这个属性对于分页滚动:
@property (nonatomic, assign, getter = isPagingEnabled) BOOL pagingEnabled;
启用和禁用分页。当启用分页功能时,传送带将在用户滚动时停止在每个项目视图中,非常类似于UIScrollView的pagingEnabled属性。
我试图改变iCarousel,而看起来它不能平稳移动,如果我改变了itemWidth。
- 所以我试图写我自己的旋转木马,现在它的作品。感谢大家。
对于宽度,您可以使用委托方法“carouselItemWidth”并使用滚动速度在时间滚动1项目 –
“scrollspeed”不用于此目的亲爱的@ saurabh-prajapati。 – mgyky
我使用了carouselItemWidth,它只能设置1个itemWidth,我想为不同的item使用不同的itemWidth。 – James