Ho creato un UICollectionView e vorrei che tutte le celle si muovessero come la modalità di modifica del trampolino su iPhone. Ho creato il mio codice shake ma non so come implementarlo. Ho celle personalizzate, quindi presumo che entri lì ma non so come verrà implementato. Grazie.UICollectionViewCell Shake
#define degreesToRadians(x) (M_PI * (x)/180.0)
#define kAnimationRotateDeg 0.5
#define kAnimationTranslateX 1.0
#define kAnimationTranslateY 1.0
//startJiggling
int count = 1;
CGAffineTransform leftWobble = CGAffineTransformMakeRotation(degreesToRadians(kAnimationRotateDeg * (count%2 ? +1 : -1)));
CGAffineTransform rightWobble = CGAffineTransformMakeRotation(degreesToRadians(kAnimationRotateDeg * (count%2 ? -1 : +1)));
CGAffineTransform moveTransform = CGAffineTransformTranslate(rightWobble, -kAnimationTranslateX, -kAnimationTranslateY);
CGAffineTransform conCatTransform = CGAffineTransformConcat(rightWobble, moveTransform);
self.transform = leftWobble; // starting point
[UIView animateWithDuration:0.1
delay:(count * 0.08)
options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
animations:^{ self.transform = conCatTransform; }
completion:nil];
Ottimo, tranne tutti, ma l'ultima cella è agitazione. quando stampo il conteggio delle celle visibili e l'array ne conta il numero 1. il numero di celle visibili è inferiore. Qualche idea? NSLog (@ "visibleCellscount% d", self.collectionView.visibleCells.count); NSLog (@ "birdscount% d", self.birds.count); – BDGapps
Scusa, non ne ho idea, senza più codice ... – fguchelaar
Ma tutte le celle sono visibili? O devi scorrere per l'ultimo? – fguchelaar