Search code examples
iosuiviewuiviewanimationuiviewanimationtransition

UIViewAnimation from view and back


I have a question regarding transitioning between uiviews. I have a view1 that transition to view2, but when i want to transition back it doesn't work.

Action called on first view to flip to the second view.

- (IBAction)flip:(id)sender {
    [UIView transitionFromView:view1 toView:view2 duration:1.0 options: UIViewAnimationOptionTransitionFlipFromLeft
                    completion: ^(BOOL inFinished) {
                    }];

}

Action called on second view:

- (IBAction)flipBack:(id)sender {
    [UIView transitionFromView:view2 toView:view1 duration:1.0 options: UIViewAnimationOptionTransitionFlipFromLeft
                    completion: ^(BOOL inFinished) {
                    }];
}

Thank you!


Solution

  • You need to hold a strong reference to both views - when view1 is removed it will be deallocated unless you keep hold of a strong reference to it.