user3294722
user3294722

Reputation: 235

Move to new view controller after animation stops

I'm new to programming Xcode/objectiveC and this questions seems like it should be painfully obvious but I cannot find an answer; how do i move to a different view controller after an animation completes (without a button or other user interaction). in other words go back to the "home" screen automatically after it finishes. right now the image that is animated just stops moving and stays there after the animation finishes and i'm stuck in that viewController.

i'm guessing the coding should have something to do with the selector but i'm not sure

[UIView setAnimationDidStopSelector:@selector ???];

thanks!

Upvotes: 0

Views: 167

Answers (1)

nhgrif
nhgrif

Reputation: 62062

UIView's animateWithDuration has a completion block in which you can put code that is executed when the animation is completed.

[UIView animateWithDuration:duration
                  animations:^{ 
                                 animations 
                             }
                  completion:^(BOOL success) {
                                 [self performSegueWithIdentifier:@"YOUR_SEGUE"];
                             }];

Upvotes: 1

Related Questions