-
-
Save johnlabarge/4725836 to your computer and use it in GitHub Desktop.
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
// | |
// TransitionController.h | |
// | |
// Created by XJones on 11/25/11. | |
// | |
#import <UIKit/UIKit.h> | |
@interface TransitionController : UIViewController | |
@property (nonatomic, strong) UIView * containerView; | |
@property (nonatomic, strong) UIViewController * viewController; | |
- (id)initWithViewController:(UIViewController *)viewController; | |
- (void)transitionToViewController:(UIViewController *)viewController | |
withOptions:(UIViewAnimationOptions)options; | |
@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
// | |
// TransitionController.m | |
// | |
// Created by XJones on 11/25/11. | |
// | |
#import "TransitionController.h" | |
@implementation TransitionController | |
@synthesize containerView = _containerView, | |
viewController = _viewController; | |
- (id)initWithViewController:(UIViewController *)viewController | |
{ | |
if (self = [super init]) { | |
_viewController = viewController; | |
} | |
return self; | |
} | |
- (void)loadView | |
{ | |
self.wantsFullScreenLayout = YES; | |
UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; | |
view.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; | |
self.view = view; | |
_containerView = [[UIView alloc] initWithFrame:view.bounds]; | |
_containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; | |
[self.view addSubview:_containerView]; | |
[_containerView addSubview:self.viewController.view]; | |
} | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | |
{ | |
return [self.viewController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; | |
} | |
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration | |
{ | |
[self.viewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; | |
} | |
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation | |
{ | |
[self.viewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; | |
} | |
- (void)transitionToViewController:(UIViewController *)aViewController | |
withOptions:(UIViewAnimationOptions)options | |
{ | |
aViewController.view.frame = self.containerView.bounds; | |
[UIView transitionWithView:self.containerView | |
duration:0.65f | |
options:options | |
animations:^{ | |
[self.viewController.view removeFromSuperview]; | |
[self.containerView addSubview:aViewController.view]; | |
} | |
completion:^(BOOL finished){ | |
self.viewController = aViewController; | |
}]; | |
} | |
@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
TransitionController | |
A UIViewController subclass that allows for easy transitions to new view controllers in any orientation with a specified transition options. | |
instance methods | |
- (void)initWithViewController:(UIViewController *)viewController | |
Initializes a new TransitionController displaying the specified viewController. | |
- (void)transitionToViewController:(UIViewController *)viewController withOptions:(UIViewAnimationOptions)options | |
Transitions to a new view controller with the specified options. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment