-
Notifications
You must be signed in to change notification settings - Fork 2
/
SegmentsController.m
executable file
·46 lines (35 loc) · 1.36 KB
/
SegmentsController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// SegmentManager.m
// NavBasedSeg
//
// Created by Marcus Crafter on 25/06/10.
// Copyright 2010 Red Artisan. All rights reserved.
//
#import "SegmentsController.h"
@interface SegmentsController ()
@property (nonatomic, retain, readwrite) NSArray * viewControllers;
@property (nonatomic, retain, readwrite) UINavigationController * navigationController;
@end
@implementation SegmentsController
@synthesize viewControllers;
@synthesize navigationController;
- (id)initWithNavigationController:(UINavigationController *)aNavigationController viewControllers:(NSArray *)theViewControllers {
if (self = [super init]) {
self.navigationController = aNavigationController;
self.viewControllers = theViewControllers;
}
return self;
}
- (void)indexDidChangeForSegmentedControl:(UISegmentedControl *)aSegmentedControl {
NSUInteger index = aSegmentedControl.selectedSegmentIndex;
UIViewController * incomingViewController = [self.viewControllers objectAtIndex:index];
NSArray * theViewControllers = [NSArray arrayWithObject:incomingViewController];
[self.navigationController setViewControllers:theViewControllers animated:NO];
incomingViewController.navigationItem.titleView = aSegmentedControl;
}
- (void)dealloc {
[super dealloc];
self.viewControllers = nil;
self.navigationController = nil;
}
@end