Skip to content

Instantly share code, notes, and snippets.

View ngutman's full-sized avatar

Nimrod Gutman ngutman

View GitHub Profile
@ngutman
ngutman / gist:7609370
Created November 23, 2013 00:52
Add a direction to the animation
- (void)loadViewController:(UIViewController *)vc
fromLeft:(BOOL)fromLeft
{
[self addChildViewController:vc];
if (!self.currentVC) {
[self.view addSubview:vc.view];
vc.view.frame = self.view.bounds;
self.currentVC = vc;
return;
}
@ngutman
ngutman / gist:7609367
Created November 23, 2013 00:51
connect it to the tabTapped
- (void)tabTapped
{
if ([self.currentVC isKindOfClass:[GGViewController1 class]]) {
[self loadViewController:[[GGViewController2 alloc] init]];
} else {
[self loadViewController:[[GGViewController1 alloc] init]];
}
}
@ngutman
ngutman / gist:7609365
Created November 23, 2013 00:51
Animate the transition
- (void)loadViewController:(UIViewController *)vc
{
[self addChildViewController:vc];
if (!self.currentVC) {
[self.view addSubview:vc.view];
vc.view.frame = self.view.bounds;
self.currentVC = vc;
return;
}
@ngutman
ngutman / gist:7609362
Created November 23, 2013 00:50
Loading the default view controller
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadTab];
[self loadViewController:[[GGViewController1 alloc] init]];
}
...
@ngutman
ngutman / gist:7609358
Created November 23, 2013 00:50
GGViewController1
#import "GGViewController1.h"
@interface GGViewController1 ()
@end
@implementation GGViewController1
- (void)viewDidLoad
{
@ngutman
ngutman / gist:7609353
Created November 23, 2013 00:49
Add the segment control
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadTab];
}
- (void)loadTab
{
self.segmentControl = [[UISegmentedControl alloc] initWithItems:@[@"View Controller 1",
@"View Controller 2"]];