Created
May 30, 2012 09:54
-
-
Save ljanzik/2835266 to your computer and use it in GitHub Desktop.
Implement Custom Segue To Use Own Animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface MySegueWithCustomAnimation : UIStoryboardSegue | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "MySegueWithCustomAnimation.h" | |
@implementation MySegueWithCustomAnimation | |
-(void)perform{ | |
UIViewController *destination = [self destinationViewController]; | |
UIViewController *source = [self sourceViewController]; | |
[destination viewWillAppear:NO]; | |
[destination viewDidAppear:NO]; | |
//[source retain]; only if ARC is not used | |
[source.view addSubview:destination.view]; | |
CGRect original = destination.view.frame; | |
destination.view.frame = CGRectMake(destination.view.frame.origin.x+destination.view.frame.size.width, 0-destination.view.frame.size.height, destination.view.frame.size.width, destination.view.frame.size.height); | |
[UIView beginAnimations:nil context:nil]; | |
destination.view.frame = CGRectMake(original.origin.x, original.origin.y, original.size.height, original.size.width); | |
[UIView commitAnimations]; | |
[self performSelector:@selector(animationDone:) withObject:destination afterDelay:0.2f]; | |
} | |
- (void)animationDone:(id)vc{ | |
UIViewController *destination = (UIViewController*)vc; | |
UINavigationController *navController = [[self sourceViewController] navigationController]; | |
[navController pushViewController:destination animated:NO]; | |
//[[self sourceViewController] release]; only if ARC is not used | |
} | |
@end |
Nope he didn't. This is a custom push segue. And by the way presentModalViewController:animated: is deprecated, if you want to make a custom modal segue use presentViewController:animated:completion: :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You forgot [[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO]; in perform method, isni't ?