25 |
25 |
26 #pragma mark - |
26 #pragma mark - |
27 #pragma mark View lifecycle |
27 #pragma mark View lifecycle |
28 -(void) viewDidLoad { |
28 -(void) viewDidLoad { |
29 [super viewDidLoad]; |
29 [super viewDidLoad]; |
30 |
30 |
31 // the list of selectable controllers |
31 // the list of selectable controllers |
32 controllerNames = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), |
32 controllerNames = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), |
33 NSLocalizedString(@"Teams",@""), |
33 NSLocalizedString(@"Teams",@""), |
34 NSLocalizedString(@"Weapons",@""), |
34 NSLocalizedString(@"Weapons",@""), |
35 NSLocalizedString(@"Schemes",@""), |
35 NSLocalizedString(@"Schemes",@""), |
52 } |
52 } |
53 |
53 |
54 // Customize the appearance of table view cells. |
54 // Customize the appearance of table view cells. |
55 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
55 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
56 static NSString *CellIdentifier = @"Cell"; |
56 static NSString *CellIdentifier = @"Cell"; |
57 |
57 |
58 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
58 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
59 if (cell == nil) { |
59 if (cell == nil) { |
60 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
60 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
61 cell.textLabel.text = [controllerNames objectAtIndex:[indexPath row]]; |
61 cell.textLabel.text = [controllerNames objectAtIndex:[indexPath row]]; |
62 } |
62 } |
63 |
63 |
64 return cell; |
64 return cell; |
65 } |
65 } |
66 |
66 |
67 #pragma mark - |
67 #pragma mark - |
68 #pragma mark Table view delegate |
68 #pragma mark Table view delegate |
69 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
69 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
70 int newRow = [indexPath row]; |
70 int newRow = [indexPath row]; |
71 int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
71 int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
72 UIViewController *nextController = nil; |
72 UIViewController *nextController = nil; |
73 |
73 |
74 if (newRow != oldRow) { |
74 if (newRow != oldRow) { |
75 [self.tableView deselectRowAtIndexPath:lastIndexPath animated:YES]; |
75 [self.tableView deselectRowAtIndexPath:lastIndexPath animated:YES]; |
76 [detailViewController.navigationController popToRootViewControllerAnimated:NO]; |
76 [detailViewController.navigationController popToRootViewControllerAnimated:NO]; |
77 |
77 |
78 switch (newRow) { |
78 switch (newRow) { |
79 case 0: |
79 case 0: |
80 if (nil == generalSettingsViewController) |
80 if (nil == generalSettingsViewController) |
81 generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
81 generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
82 nextController = generalSettingsViewController; |
82 nextController = generalSettingsViewController; |
95 if (nil == schemeSettingsViewController) |
95 if (nil == schemeSettingsViewController) |
96 schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
96 schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
97 nextController = schemeSettingsViewController; |
97 nextController = schemeSettingsViewController; |
98 break; |
98 break; |
99 } |
99 } |
100 |
100 |
101 nextController.navigationItem.hidesBackButton = YES; |
101 nextController.navigationItem.hidesBackButton = YES; |
102 nextController.title = [controllerNames objectAtIndex:newRow]; |
102 nextController.title = [controllerNames objectAtIndex:newRow]; |
103 [detailViewController.navigationController pushViewController:nextController animated:NO]; |
103 [detailViewController.navigationController pushViewController:nextController animated:NO]; |
104 self.lastIndexPath = indexPath; |
104 self.lastIndexPath = indexPath; |
105 [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
105 [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
110 #pragma mark - |
110 #pragma mark - |
111 #pragma mark Memory management |
111 #pragma mark Memory management |
112 -(void) didReceiveMemoryWarning { |
112 -(void) didReceiveMemoryWarning { |
113 // Releases the view if it doesn't have a superview. |
113 // Releases the view if it doesn't have a superview. |
114 [super didReceiveMemoryWarning]; |
114 [super didReceiveMemoryWarning]; |
115 // Relinquish ownership any cached data, images, etc that aren't in use. |
115 // Relinquish ownership any cached data, images, etc that aren't in use. |
116 if (generalSettingsViewController.view.superview == nil) |
116 if (generalSettingsViewController.view.superview == nil) |
117 generalSettingsViewController = nil; |
117 generalSettingsViewController = nil; |
118 if (teamSettingsViewController.view.superview == nil) |
118 if (teamSettingsViewController.view.superview == nil) |
119 teamSettingsViewController = nil; |
119 teamSettingsViewController = nil; |
120 if (weaponSettingsViewController.view.superview == nil) |
120 if (weaponSettingsViewController.view.superview == nil) |