|
1 /* |
|
2 * Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 * Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 * |
|
18 * File created on 30/12/2010. |
|
19 */ |
|
20 |
|
21 |
|
22 #import "StatsPageViewController.h" |
|
23 #import "CommodityFunctions.h" |
|
24 |
|
25 @implementation StatsPageViewController |
|
26 @synthesize statsDictionary; |
|
27 |
|
28 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
29 return rotationManager(interfaceOrientation); |
|
30 } |
|
31 |
|
32 #pragma mark - |
|
33 #pragma mark Table view data source |
|
34 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
35 return 2; |
|
36 } |
|
37 |
|
38 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
39 if (section == 0) |
|
40 return [[self.statsDictionary allValues] count]; |
|
41 else |
|
42 return 1; |
|
43 } |
|
44 |
|
45 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
46 static NSString *CellIdentifier0 = @"Cell0"; |
|
47 |
|
48 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
|
49 if (cell == nil) |
|
50 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
|
51 |
|
52 cell.textLabel.textAlignment = UITextAlignmentCenter; |
|
53 if ([indexPath section] == 0) { |
|
54 cell.textLabel.text = [[self.statsDictionary allValues] objectAtIndex:[indexPath row]]; |
|
55 } else { |
|
56 cell.textLabel.text = NSLocalizedString(@"Back",@""); |
|
57 } |
|
58 |
|
59 return cell; |
|
60 } |
|
61 |
|
62 |
|
63 #pragma mark - |
|
64 #pragma mark Table view delegate |
|
65 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
66 if ([indexPath section] == 2) |
|
67 [self dismissModalViewControllerAnimated:YES]; |
|
68 } |
|
69 |
|
70 #pragma mark - |
|
71 #pragma mark Memory management |
|
72 -(void) didReceiveMemoryWarning { |
|
73 // Releases the view if it doesn't have a superview. |
|
74 [super didReceiveMemoryWarning]; |
|
75 // Relinquish ownership any cached data, images, etc. that aren't in use. |
|
76 } |
|
77 |
|
78 -(void) dealloc { |
|
79 [statsDictionary release]; |
|
80 [super dealloc]; |
|
81 } |
|
82 |
|
83 |
|
84 @end |
|
85 |