Unwind for more than 1 sec using iOS 7 transition animation UIViewController

I am using UIViewController animated transitions introduced in iOS7. I can create some really big transitions going back and forth between VCs using segues etc.

Take a look at my photo below:

enter image description here

I can very easily go back and forth if it's just one segue / vc at a time. For example, if I go from screen 1 to screen 2, the animation works fine. And then say I go back to 1 or go to 3, it works fine.

But if you notice on screen 4 at the bottom, a button will appear that says “Back to screen 1” - this expands the segue to screen 1. The problem is that I can not get the transition animation to work. In fact, the delegate methods are never called.

(, 2 3):

//This is found in screen 2 view controller .m

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

    if ([segue.identifier isEqualToString:@"screen2to3"]) {

        UIViewController *destination = segue.destinationViewController;
        destination.transitioningDelegate = self;
        destination.modalTransitionStyle = UIModalPresentationCustom;

    }
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {

    STSlideAnimation *animator = [STSlideAnimation new];
    animator.presenting = YES;
    return animator;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {

    STSlideAnimation *animator = [STSlideAnimation new];
    return animator;
}

//This is the unwinding segue action

-(IBAction)returnToScreen2:(UIStoryboardSegue *)segue{

}

3, 2. . , , , vc . ? , .

+4
1

segue ,

#import <UIKit/UIKit.h>

@interface CustomSegue : UIStoryboardSegue

@end


@implementation CustomSegue

 -(void)perform {

 // write your transition code here
 // this code will be called every time transition is made

}

segue storybord - - , "CustomSegue"

, , .

Segue inspector

, , 4- 1-

+2

Source: https://habr.com/ru/post/1525140/


All Articles