5 // Created by Vittorio on 02/04/10. |
5 // Created by Vittorio on 02/04/10. |
6 // Copyright 2010 __MyCompanyName__. All rights reserved. |
6 // Copyright 2010 __MyCompanyName__. All rights reserved. |
7 // |
7 // |
8 |
8 |
9 #import "SingleTeamViewController.h" |
9 #import "SingleTeamViewController.h" |
10 |
10 #import "HogHatViewController.h" |
11 |
11 |
12 @implementation SingleTeamViewController |
12 @implementation SingleTeamViewController |
13 @synthesize hogsList, secondaryItems; |
13 @synthesize hogsList, secondaryItems, teamName; |
14 |
14 |
15 |
15 |
16 #pragma mark - |
16 #pragma mark - |
17 #pragma mark View lifecycle |
17 #pragma mark View lifecycle |
18 - (void)viewDidLoad { |
18 - (void)viewDidLoad { |
19 [super viewDidLoad]; |
19 [super viewDidLoad]; |
20 |
20 |
21 |
|
22 // Uncomment the following line to preserve selection between presentations. |
21 // Uncomment the following line to preserve selection between presentations. |
23 //self.clearsSelectionOnViewWillAppear = NO; |
22 //self.clearsSelectionOnViewWillAppear = NO; |
24 |
23 |
25 // Uncomment the following line to display an Edit button in the navigation bar for this view controller. |
24 // Uncomment the following line to display an Edit button in the navigation bar for this view controller. |
26 // self.navigationItem.rightBarButtonItem = self.editButtonItem; |
25 // self.navigationItem.rightBarButtonItem = self.editButtonItem; |
27 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
26 |
28 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@Teams/%@.plist",[paths objectAtIndex:0],self.title]; |
|
29 NSDictionary *teamDict = [[NSDictionary alloc] initWithContentsOfFile: teamFile]; |
|
30 [teamFile release]; |
|
31 self.hogsList = [teamDict objectForKey:@"hedgehogs"]; |
|
32 [teamDict release]; |
|
33 |
|
34 NSMutableArray *array = [[NSMutableArray alloc] initWithObjects: |
27 NSMutableArray *array = [[NSMutableArray alloc] initWithObjects: |
35 NSLocalizedString(@"Color",@""), |
28 NSLocalizedString(@"Color",@""), |
36 NSLocalizedString(@"Grave",@""), |
29 NSLocalizedString(@"Grave",@""), |
37 NSLocalizedString(@"Voice",@""), |
30 NSLocalizedString(@"Voice",@""), |
38 NSLocalizedString(@"Fort",@""), |
31 NSLocalizedString(@"Fort",@""), |
41 self.secondaryItems = array; |
34 self.secondaryItems = array; |
42 [array release]; |
35 [array release]; |
43 } |
36 } |
44 |
37 |
45 |
38 |
46 /* |
|
47 - (void)viewWillAppear:(BOOL)animated { |
39 - (void)viewWillAppear:(BOOL)animated { |
48 [super viewWillAppear:animated]; |
40 [super viewWillAppear:animated]; |
49 } |
41 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
50 */ |
42 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@Teams/%@.plist",[paths objectAtIndex:0],self.teamName]; |
|
43 NSDictionary *teamDict = [[NSDictionary alloc] initWithContentsOfFile:teamFile]; |
|
44 [teamFile release]; |
|
45 |
|
46 self.hogsList = [teamDict objectForKey:@"hedgehogs"]; |
|
47 self.teamName = [teamDict objectForKey:@"teamname"]; |
|
48 [teamDict release]; |
|
49 self.title = teamName; |
|
50 } |
|
51 |
51 /* |
52 /* |
52 - (void)viewDidAppear:(BOOL)animated { |
53 - (void)viewDidAppear:(BOOL)animated { |
53 [super viewDidAppear:animated]; |
54 [super viewDidAppear:animated]; |
54 } |
55 } |
55 */ |
56 */ |
62 - (void)viewDidDisappear:(BOOL)animated { |
63 - (void)viewDidDisappear:(BOOL)animated { |
63 [super viewDidDisappear:animated]; |
64 [super viewDidDisappear:animated]; |
64 } |
65 } |
65 */ |
66 */ |
66 |
67 |
67 |
|
68 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
68 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
69 // Override to allow orientations other than the default portrait orientation. |
|
70 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
69 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
71 } |
70 } |
72 |
71 |
73 |
72 |
74 #pragma mark - |
73 #pragma mark - |
75 #pragma mark Table view data source |
74 #pragma mark Table view data source |
76 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
75 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
77 // Return the number of sections. |
|
78 return 3; |
76 return 3; |
79 } |
77 } |
80 |
78 |
81 |
|
82 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
79 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
83 // Return the number of rows in the section. |
|
84 NSInteger rows; |
80 NSInteger rows; |
85 switch (section) { |
81 switch (section) { |
86 case 0: |
82 case 0: |
87 rows = 1; |
83 rows = 1; |
88 break; |
84 break; |
96 break; |
92 break; |
97 } |
93 } |
98 return rows; |
94 return rows; |
99 } |
95 } |
100 |
96 |
101 |
|
102 // Customize the appearance of table view cells. |
|
103 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
97 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
104 |
|
105 static NSString *CellIdentifier = @"Cell"; |
98 static NSString *CellIdentifier = @"Cell"; |
106 |
99 |
107 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
100 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
108 if (cell == nil) { |
101 if (cell == nil) { |
109 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
102 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
103 reuseIdentifier:CellIdentifier] autorelease]; |
110 } |
104 } |
111 |
105 |
112 NSInteger row = [indexPath row]; |
106 NSInteger row = [indexPath row]; |
113 switch ([indexPath section]) { |
107 switch ([indexPath section]) { |
114 case 0: |
108 case 0: |
115 cell.textLabel.text = self.title; |
109 cell.textLabel.text = teamName; |
116 break; |
110 break; |
117 case 1: |
111 case 1: |
118 cell.textLabel.text = [[self.hogsList objectAtIndex:row] objectForKey:@"hogname"]; |
112 cell.textLabel.text = [[self.hogsList objectAtIndex:row] objectForKey:@"hogname"]; |
|
113 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
119 break; |
114 break; |
120 case 2: |
115 case 2: |
121 cell.textLabel.text = [self.secondaryItems objectAtIndex:row]; |
116 cell.textLabel.text = [self.secondaryItems objectAtIndex:row]; |
122 break; |
117 break; |
123 default: |
118 default: |
170 |
165 |
171 #pragma mark - |
166 #pragma mark - |
172 #pragma mark Table view delegate |
167 #pragma mark Table view delegate |
173 |
168 |
174 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
169 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
175 // Navigation logic may go here. Create and push another view controller. |
170 if (nil == hogChildController) { |
176 /* |
171 hogChildController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
177 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; |
172 } |
178 // ... |
173 |
179 // Pass the selected object to the new view controller. |
174 hogChildController.hog = [hogsList objectAtIndex:[indexPath row]]; |
180 [self.navigationController pushViewController:detailViewController animated:YES]; |
175 //NSLog(@"%@",hogChildController.hog); |
181 [detailViewController release]; |
176 [self.navigationController pushViewController:hogChildController animated:YES]; |
182 */ |
|
183 } |
177 } |
184 |
178 |
185 |
179 |
186 #pragma mark - |
180 #pragma mark - |
187 #pragma mark Memory management |
181 #pragma mark Memory management |
188 |
182 |
189 -(void) didReceiveMemoryWarning { |
183 -(void) didReceiveMemoryWarning { |
190 // Releases the view if it doesn't have a superview. |
184 // Releases the view if it doesn't have a superview. |
191 [super didReceiveMemoryWarning]; |
185 [super didReceiveMemoryWarning]; |
192 |
|
193 // Relinquish ownership any cached data, images, etc that aren't in use. |
186 // Relinquish ownership any cached data, images, etc that aren't in use. |
194 } |
187 } |
195 |
188 |
196 -(void) viewDidUnload { |
189 -(void) viewDidUnload { |
197 self.hogsList = nil; |
190 self.hogsList = nil; |
198 self.secondaryItems = nil; |
191 self.secondaryItems = nil; |
|
192 self.teamName = nil; |
199 } |
193 } |
200 |
194 |
201 |
195 |
202 -(void) dealloc { |
196 -(void) dealloc { |
|
197 [secondaryItems release]; |
203 [hogsList release]; |
198 [hogsList release]; |
204 [secondaryItems release]; |
199 [teamName release]; |
205 [super dealloc]; |
200 [super dealloc]; |
206 } |
201 } |
207 |
202 |
208 |
203 |
209 @end |
204 @end |