Ich habe eine Sammlung in dem ich 10 Bilder von Webservice geladen habe. Ich möchte diese Bildansicht von der ersten zur letzten Position automatisch scrollen und dann dauernd zur ersten Position dauern, wenn diese Seite erscheint. Ich benutze unten MethodeAnimation des Scrollens in Sammlungsansicht in IOS
-(void)scrollSlowly
{
CATransition *transition = [CATransition animation];
transition.duration = 4.0f;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[UIView animateWithDuration:5.0f
delay:3.0f
options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
animations:^{
[self.CollectionView setContentOffset:CGPointMake(CGFLOAT_MAX ,0)];
}
completion:nil];
[self.CollectionView.layer addAnimation:transition forKey:@"transition"];
}
-(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+1, self.scrollingPoint.y);
}
I horizontal in Objective-C zu Autoscroll wollen. Vielen Dank im Voraus
Warum würden Sie nicht verwenden '- (void) scrollToItemAtIndexPath: (NSIndexPath *) indexPath atScrollPosition: (UICollectionViewScrollPosition) scroll animiert: (BOOL) animiert? – s0urcer
Ja, ich benutze das auch, aber es wird mir nicht repetitive langsam scrollen ... @sourcer – Aashi