0
타이머를 사용하여 가로 자동 스크롤을 사용하고 있습니다. 하나씩 스크롤하고 싶습니다.UICollectionView - 타이머가있는 가로 자동 스크롤
필자의 경우에는 왼쪽에서 오른쪽으로 continuos를 스크롤하고있다. 마지막으로 마지막 셀 다음에 공백을 스크롤합니다.
@interface AccountsVC()<UICollectionViewDataSource, UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
{
CGFloat width_Cell;
NSTimer *autoScrollTimer;
}
- (void)viewDidLoad
{
[super viewDidLoad];
width_Cell = 0.0;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self configAutoscrollTimer];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self deconfigAutoscrollTimer];
}
- (void)configAutoscrollTimer
{
autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
}
- (void)deconfigAutoscrollTimer
{
[autoScrollTimer invalidate];
autoScrollTimer = nil;
}
- (void)onTimer
{
[self autoScrollView];
}
- (void)autoScrollView
{
CGPoint initailPoint = CGPointMake(width_Cell, 0);
if (CGPointEqualToPoint(initailPoint, self.collectionView.contentOffset))
{
if (width_Cell < self.collectionView.contentSize.width)
{
width_Cell += 0.5;
}else
{
width_Cell = -self.view.frame.size.width;
}
CGPoint offsetPoint = CGPointMake(width_Cell, 0);
self.collectionView.contentOffset = offsetPoint;
}else
{
width_Cell = self.collectionView.contentOffset.x;
}
}
당신의 collectionview 세포 폭이 self.width 같다있는 viewDidLoad에서 변수
전화를 선언이
처럼 사용하고 ??? 또는 스크롤 셀 3 다음에 처음으로 3 개의 셀을 표시합니까? –
@AgentChocks. 어레이 카운트를 기반으로 한 모든 것이 없습니다. 배열에서 첫 번째 요소부터 끝까지 스크롤 한 다음 역순으로 뒤 스크롤 – ChenSmile
@AgentChocks. 너 어떤 해결책이있어? – ChenSmile