3250
|
1 |
//
|
|
2 |
// SingleTeamViewController.m
|
|
3 |
// HedgewarsMobile
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 02/04/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "SingleTeamViewController.h"
|
|
10 |
|
|
11 |
|
|
12 |
@implementation SingleTeamViewController
|
3253
|
13 |
@synthesize hogsList, secondaryItems;
|
3250
|
14 |
|
|
15 |
|
|
16 |
#pragma mark -
|
|
17 |
#pragma mark View lifecycle
|
|
18 |
- (void)viewDidLoad {
|
|
19 |
[super viewDidLoad];
|
|
20 |
|
3253
|
21 |
|
3250
|
22 |
// Uncomment the following line to preserve selection between presentations.
|
3253
|
23 |
//self.clearsSelectionOnViewWillAppear = NO;
|
3250
|
24 |
|
|
25 |
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
|
|
26 |
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
3253
|
27 |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
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];
|
3251
|
33 |
|
|
34 |
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:
|
|
35 |
NSLocalizedString(@"Color",@""),
|
|
36 |
NSLocalizedString(@"Grave",@""),
|
|
37 |
NSLocalizedString(@"Voice",@""),
|
|
38 |
NSLocalizedString(@"Fort",@""),
|
|
39 |
NSLocalizedString(@"Flag",@""),
|
|
40 |
NSLocalizedString(@"Level",@""),nil];
|
|
41 |
self.secondaryItems = array;
|
|
42 |
[array release];
|
3250
|
43 |
}
|
3251
|
44 |
|
3250
|
45 |
|
|
46 |
/*
|
|
47 |
- (void)viewWillAppear:(BOOL)animated {
|
|
48 |
[super viewWillAppear:animated];
|
|
49 |
}
|
|
50 |
*/
|
|
51 |
/*
|
|
52 |
- (void)viewDidAppear:(BOOL)animated {
|
|
53 |
[super viewDidAppear:animated];
|
|
54 |
}
|
|
55 |
*/
|
|
56 |
/*
|
|
57 |
- (void)viewWillDisappear:(BOOL)animated {
|
|
58 |
[super viewWillDisappear:animated];
|
|
59 |
}
|
|
60 |
*/
|
|
61 |
/*
|
|
62 |
- (void)viewDidDisappear:(BOOL)animated {
|
|
63 |
[super viewDidDisappear:animated];
|
|
64 |
}
|
|
65 |
*/
|
|
66 |
|
|
67 |
|
3251
|
68 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
3250
|
69 |
// Override to allow orientations other than the default portrait orientation.
|
3251
|
70 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
3250
|
71 |
}
|
|
72 |
|
|
73 |
|
|
74 |
#pragma mark -
|
|
75 |
#pragma mark Table view data source
|
|
76 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
|
|
77 |
// Return the number of sections.
|
|
78 |
return 3;
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
83 |
// Return the number of rows in the section.
|
|
84 |
NSInteger rows;
|
|
85 |
switch (section) {
|
|
86 |
case 0:
|
|
87 |
rows = 1;
|
|
88 |
break;
|
|
89 |
case 1:
|
|
90 |
rows = 8;
|
|
91 |
break;
|
|
92 |
case 2:
|
3251
|
93 |
rows = 6;
|
3250
|
94 |
break;
|
|
95 |
default:
|
|
96 |
break;
|
|
97 |
}
|
|
98 |
return rows;
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
// Customize the appearance of table view cells.
|
3251
|
103 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
3250
|
104 |
|
|
105 |
static NSString *CellIdentifier = @"Cell";
|
|
106 |
|
|
107 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
|
108 |
if (cell == nil) {
|
|
109 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
|
|
110 |
}
|
|
111 |
|
3253
|
112 |
NSInteger row = [indexPath row];
|
3251
|
113 |
switch ([indexPath section]) {
|
3253
|
114 |
case 0:
|
|
115 |
cell.textLabel.text = self.title;
|
|
116 |
break;
|
|
117 |
case 1:
|
|
118 |
cell.textLabel.text = [[self.hogsList objectAtIndex:row] objectForKey:@"hogname"];
|
|
119 |
break;
|
3251
|
120 |
case 2:
|
3253
|
121 |
cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
|
3251
|
122 |
break;
|
|
123 |
default:
|
|
124 |
break;
|
|
125 |
}
|
3250
|
126 |
|
|
127 |
return cell;
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
/*
|
|
132 |
// Override to support conditional editing of the table view.
|
|
133 |
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
134 |
// Return NO if you do not want the specified item to be editable.
|
|
135 |
return YES;
|
|
136 |
}
|
|
137 |
*/
|
|
138 |
|
|
139 |
|
|
140 |
/*
|
|
141 |
// Override to support editing the table view.
|
|
142 |
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
143 |
|
|
144 |
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
|
145 |
// Delete the row from the data source
|
|
146 |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
|
|
147 |
}
|
|
148 |
else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
|
149 |
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
|
|
150 |
}
|
|
151 |
}
|
|
152 |
*/
|
|
153 |
|
|
154 |
|
|
155 |
/*
|
|
156 |
// Override to support rearranging the table view.
|
|
157 |
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
158 |
}
|
|
159 |
*/
|
|
160 |
|
|
161 |
|
|
162 |
/*
|
|
163 |
// Override to support conditional rearranging of the table view.
|
|
164 |
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
165 |
// Return NO if you do not want the item to be re-orderable.
|
|
166 |
return YES;
|
|
167 |
}
|
|
168 |
*/
|
|
169 |
|
|
170 |
|
|
171 |
#pragma mark -
|
|
172 |
#pragma mark Table view delegate
|
|
173 |
|
3251
|
174 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
3250
|
175 |
// Navigation logic may go here. Create and push another view controller.
|
|
176 |
/*
|
|
177 |
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
|
|
178 |
// ...
|
|
179 |
// Pass the selected object to the new view controller.
|
|
180 |
[self.navigationController pushViewController:detailViewController animated:YES];
|
|
181 |
[detailViewController release];
|
|
182 |
*/
|
|
183 |
}
|
|
184 |
|
|
185 |
|
|
186 |
#pragma mark -
|
|
187 |
#pragma mark Memory management
|
|
188 |
|
3251
|
189 |
-(void) didReceiveMemoryWarning {
|
3250
|
190 |
// Releases the view if it doesn't have a superview.
|
|
191 |
[super didReceiveMemoryWarning];
|
|
192 |
|
|
193 |
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
194 |
}
|
|
195 |
|
3251
|
196 |
-(void) viewDidUnload {
|
3253
|
197 |
self.hogsList = nil;
|
3251
|
198 |
self.secondaryItems = nil;
|
3250
|
199 |
}
|
|
200 |
|
|
201 |
|
3251
|
202 |
-(void) dealloc {
|
3253
|
203 |
[hogsList release];
|
3251
|
204 |
[secondaryItems release];
|
3250
|
205 |
[super dealloc];
|
|
206 |
}
|
|
207 |
|
|
208 |
|
|
209 |
@end
|
|
210 |
|