The horizontal direction of the flip in the excavation iOS

I installed two view managers on my storyboard, each with an action button. I installed two segments:

  • From the first view controller to the second view controller: Modal, Flip Horizontal.
  • From the second view controller to the first view controller: Modal, Flip Horizontal.

Everything works, but I would like it to flip one way and back, now it flips the same direction for both controllers.

What is the easiest way to make the flip effect?

+5
source share
3 answers

I ran into the same problem and hopefully found a solution.

I used a special transition to lean back. Here is the code of myFlipLeftSegue

@implementation FlipLeftSegue
- (void)perform
{
    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;    

    [UIView beginAnimations:@"LeftFlip" context:nil];
    [UIView setAnimationDuration:0.8];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:src.view.superview cache:YES];
    [UIView commitAnimations];

    [src presentViewController:dst animated:NO completion:nil];
}
@end

, , , viewDidAppear . , segue .

+6

ViewController ViewController ViewController, -dismissViewControllerAnimated: : . :

-(IBAction)someResponderToYourCancelButtonOrWhatever:(id)sender {
    // Do some stuff
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
+5

You better use this code in NSZombie's answer:

- (void)swapChildVCFrom:(UIViewController *)from to:(UIViewController *)to options:(enum UIViewAnimationOptions)options
{
    [self addChildViewController:to];
    [from willMoveToParentViewController:nil];

    // Adjust the new child view controller view frame
    // For example here just set it to fill the parent view
    to.view.frame = self.view.bounds;

    [self transitionFromViewController:from
                      toViewController:to
                              duration:1.0
                               options:options
                            animations:nil
                            completion:^(BOOL b)
                            {
                                [to didMoveToParentViewController:self];
                                [from.view removeFromSuperview];
                                [from removeFromParentViewController];
                            }];
}
+1
source

All Articles