Displacing one view with another with a custom segue animation?

Go To StackoverFlow.com

1

I am trying to implement SUBJ but can't make destination segue appear in my animation. I want to make animation for view change where new segue will displace old one. Currently my perform method looks like this:

- (void) perform {

UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;

[UIView animateWithDuration:2.0
                 animations:^{

                 //tried a lot of staff to make dst view to fall from top at the same time as current view falling to bottom but failed. 

                 src.view.transform=CGAffineTransformMakeTranslation(0, 480);
                 }
                 completion:^(BOOL finished){ 
                     [[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
                 }
    ];
}

Any ideas how can I add to my animation block new view appearing from top?

Many thanks!

EDIT:

- (void) perform {

    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;

    src.view.transform = CGAffineTransformMakeTranslation(0, 0);
    dst.view.transform = CGAffineTransformMakeTranslation(0, -480);

    [UIView animateWithDuration:2.0
                 animations:^{
                         [src.view addSubview:dst.view];
                         src.view.transform = CGAffineTransformMakeTranslation(0, 460);

                     }
                     completion:^(BOOL finished){ 
                         [src presentModalViewController:dst animated:NO];
                     }
     ];

}

Thats how I did it in the end.

2012-04-05 19:12
by Alexandr
it's this easy ! ... http://stackoverflow.com/a/25482006/29488 - Fattie 2014-08-25 08:43


4

I don't quite get what you mean by new and old so i assume new = dst and old = src.

- (void) perform {

   UIViewController *src = (UIViewController *) self.sourceViewController;
   UIViewController *dst = (UIViewController *) self.destinationViewController;

   src.view.transform = CGAffineTransformMakeTranslation(0, 0);
   dst.view.transform = CGAffineTransformMakeTranslation(0, -480);

   [UIView animateWithDuration:2.0
                 animations:^{
                     [src presentModalViewController:dst animated:NO];
                     src.view.transform = CGAffineTransformMakeTranslation(0, 480);
                     dst.view.transform = CGAffineTransformMakeTranslation(0, 0);
                 }
   ];
}

This should do it.

2012-04-05 19:25
by yinkou
Thank you for your reply. Sure u were right, new is dst. Somehow nothing changed and during animation dst view isn't appearing. Also I didn't get why presentModalViewController is wrong here. link I took it from here - Alexandr 2012-04-05 19:45
You are right, sry i'm not that much into storyboarding. Upped my answer.
I hope, that'll help. this is my last chance to look serious. ; - yinkou 2012-04-05 20:09
Thanks again for helping me. What I found trying ur code now: animation happens on different views. So if I use ur code and change view before animation completes I will see just dst view animating. Any ideas how can I make them both animate at the same time without some dirty patches like one big super view or some other unpleasant code? To makke it clear. If I use presentModalViewController before after completion I see only src view animating. If I use it before I see only second view animating. And I have no idea how to combine the - Alexandr 2012-04-05 20:16
before after completion = before animation completion - Alexandr 2012-04-05 20:22
Ads