Ich implementiere einige einfache Animationen in meine Karten-App.
Bis jetzt funktioniert alles prima, aber ich muss noch ein Detail ausbessern, bevor ich sagen kann, dass es fertig ist.
Das Szenario ist ziemlich einfach:
Drei Karten müssen den Bildschirm mit einer Animation verlassen, bevor Segue modal den neuen Bildschirm aufruft.
Bis jetzt wird die Animation ausgeführt und die neue Ansicht geladen, aber das Detail, das ich nicht lösen konnte, ist das "Warten, bis die Animation beendet ist, bevor die neue Ansicht angezeigt wird".
Ich gehe folgendermaßen vor:
1) Mit dieser Methode die Ausstiegsanimation einstellen
- (void)performExitAnimationWithCompletionBlock:(void (^)(BOOL))block
{
[UIView animateWithDuration:0.1f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
self.optionOneFront.center = self.optionOneBack.center = self.optionTwoFront.center;
self.optionOneFront.transform = self.optionOneBack.transform = self.optionTwoFront.transform;
self.optionThreeFront.center = self.optionThreeBack.center = self.optionTwoFront.center;
self.optionThreeFront.transform = self.optionThreeBack.transform = self.optionTwoFront.transform;
}
completion:^(BOOL finished)
{
CGPoint point = CGPointMake(self.optionTwoFront.center.x, self.view.frame.size.height * -2.0f);
[UIView animateWithDuration:1.0f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
self.optionOneFront.center = point;
self.optionOneBack.center = point;
self.optionTwoFront.center = point;
self.optionTwoBack.center = point;
self.optionThreeFront.center = point;
self.optionThreeBack.center = point;
}
completion:block];
}];
}
2) Versuchen Sie, den Segue-Code in die Animation einzubinden, bevor Sie die "AddOptions" VC
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
[self performExitAnimationWithCompletionBlock:^(BOOL finished)
{
// Executes the following "if" statement if the user wants to add new options
if ([segue.identifier isEqualToString:@"AddOptions"])
{
UINavigationController *navigationController = segue.destinationViewController;
OptionsViewController *controller = (OptionsViewController *)navigationController.topViewController;
controller.delegate = self;
}
}];
}
Wie ich bereits sagte, funktioniert alles, aber das modale Fenster erscheint, bevor die Animation beendet ist.
Haben Sie eine Idee, was ich übersehen habe?