Ich habe eine UICollectionView erstellt und möchte, dass alle Zellen wie der Bearbeitungsmodus des Sprungbretts auf dem iPhone schütteln. Ich habe meinen Shake-Code erstellt, weiß aber nicht, wie ich ihn umsetzen soll. Ich habe benutzerdefinierte Zellen, also nehme ich an, dass es dort hineingeht, aber ich weiß nicht, wie es implementiert wird. Danke.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];
Great except alle, aber die letzte Zelle ist Schütteln. Wenn ich die Anzahl der sichtbaren Zellen ausdrücke und das Array um 1 abzählt, ist die Anzahl der sichtbaren Zellen geringer. Irgendwelche Ideen? NSLog (@ "visibleCellscount% d", self.collectionView.visibleCells.count); NSLog (@ "birdscount% d", self.birds.count); – BDGapps
Sorry, keine Ahnung dafür, ohne mehr Code ... – fguchelaar
Aber alle Zellen sind sichtbar? Oder musst du für den letzten scrollen? – fguchelaar