我想从第一个项目到最后一个缓慢的自动滚动动画,然后重复.
有没有人能够做这项工作?我可以使滚动工作
[myCollection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:(myImages.count -1) inSection:0] atScrollposition:UICollectionVIEwScrollpositionRight animated:YES];
但这太过分了!
[UIVIEw animateWithDuration:10 delay:2 options:(UIVIEwAnimationoptionautoreverse + UIVIEwAnimationoptionRepeat) animations:^{ [myCollection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:(myImages.count -1) inSection:0] atScrollposition:UICollectionVIEwScrollpositionRight animated:NO];} completion:nil];
这产生了所需的滚动速度,但是只有最后几个单元格在系列中可见.我怀疑他们(甚至起始的可见细胞)正在出场.
有什么想法吗?
解决方法 你可以尝试这种方法:@property (nonatomic,assign) CGPoint scrollingPoint,endPoint;@property (nonatomic,strong) NSTimer *scrollingTimer;@synthesize scrollingPoint,endPoint;@synthesize scrollingTimer;- (voID)scrollSlowly { // Set the point where the scrolling stops. self.endPoint = CGPointMake(0,300); // Assuming that you are starting at {0,0} and scrolling along the x-axis. self.scrollingPoint = CGPointMake(0,0); // Change the timer interval for speed regulation. self.scrollingTimer = [NSTimer scheduledTimerWithTimeInterval:0.015 target:self selector:@selector(scrollSlowlytopoint) userInfo:nil repeats:YES];}- (voID)scrollSlowlytopoint { self.collectionVIEw.contentOffset = self.scrollingPoint; // Here you have to respond to user interactions or else the scrolling will not stop until it reaches the endPoint. if (CGPointEqualtopoint(self.scrollingPoint,self.endPoint)) { [self.scrollingTimer invalIDate]; } // Going one pixel to the right. self.scrollingPoint = CGPointMake(self.scrollingPoint.x,self.scrollingPoint.y+1);}总结
以上是内存溢出为你收集整理的ios – 在UICollectionView中创建缓慢滚动到indexPath全部内容,希望文章能够帮你解决ios – 在UICollectionView中创建缓慢滚动到indexPath所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)