3305
|
1 |
//
|
|
2 |
// MasterViewController.m
|
|
3 |
// HedgewarsMobile
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 27/03/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "MasterViewController.h"
|
|
10 |
#import "DetailViewController.h"
|
3312
|
11 |
#import "GeneralSettingsViewController.h"
|
3305
|
12 |
#import "TeamSettingsViewController.h"
|
|
13 |
|
|
14 |
@implementation MasterViewController
|
3312
|
15 |
@synthesize detailViewController, optionList, controllers;
|
3305
|
16 |
|
|
17 |
#pragma mark -
|
|
18 |
#pragma mark View lifecycle
|
|
19 |
|
|
20 |
|
|
21 |
- (void)viewDidLoad {
|
|
22 |
[super viewDidLoad];
|
|
23 |
optionList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""),
|
|
24 |
NSLocalizedString(@"Teams",@""),
|
|
25 |
NSLocalizedString(@"Weapons",@""),
|
|
26 |
NSLocalizedString(@"Schemes",@""),
|
|
27 |
nil];
|
3312
|
28 |
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:0
|
|
29 |
target:self
|
|
30 |
action:@selector(dismissSplitView)];
|
|
31 |
|
|
32 |
NSMutableArray *array= [[NSMutableArray alloc] init];
|
3305
|
33 |
|
3312
|
34 |
GeneralSettingsViewController *generalSettingsViewController = [[GeneralSettingsViewController alloc]
|
|
35 |
initWithStyle:UITableViewStyleGrouped];
|
|
36 |
generalSettingsViewController.title = NSLocalizedString(@"General",@"");
|
|
37 |
generalSettingsViewController.navigationItem.hidesBackButton = YES;
|
|
38 |
[array addObject:generalSettingsViewController];
|
|
39 |
[generalSettingsViewController release];
|
|
40 |
|
|
41 |
TeamSettingsViewController *teamSettingsViewController = [[TeamSettingsViewController alloc]
|
|
42 |
initWithStyle:UITableViewStyleGrouped];
|
|
43 |
teamSettingsViewController.title = NSLocalizedString(@"Teams",@"");
|
|
44 |
teamSettingsViewController.navigationItem.hidesBackButton = YES;
|
|
45 |
[array addObject:teamSettingsViewController];
|
|
46 |
[teamSettingsViewController release];
|
|
47 |
|
|
48 |
self.controllers = array;
|
|
49 |
[array release];
|
3305
|
50 |
// Uncomment the following line to preserve selection between presentations.
|
|
51 |
//self.clearsSelectionOnViewWillAppear = NO;
|
|
52 |
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
|
|
53 |
//self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
|
54 |
}
|
|
55 |
|
|
56 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
57 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
#pragma mark -
|
|
62 |
#pragma mark Table view data source
|
|
63 |
|
|
64 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
|
|
65 |
return 1;
|
|
66 |
}
|
|
67 |
|
|
68 |
|
|
69 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
70 |
return [optionList count];
|
|
71 |
}
|
|
72 |
|
|
73 |
|
|
74 |
// Customize the appearance of table view cells.
|
|
75 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
76 |
static NSString *CellIdentifier = @"Cell";
|
|
77 |
|
|
78 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
|
79 |
if (cell == nil) {
|
|
80 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
|
|
81 |
cell.textLabel.text = [optionList objectAtIndex:[indexPath row]];
|
|
82 |
}
|
|
83 |
|
|
84 |
return cell;
|
|
85 |
}
|
|
86 |
|
|
87 |
/*
|
|
88 |
// Override to support editing the table view.
|
|
89 |
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
90 |
|
|
91 |
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
|
92 |
// Delete the row from the data source
|
|
93 |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
|
|
94 |
}
|
|
95 |
else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
|
96 |
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
|
|
97 |
}
|
|
98 |
}
|
|
99 |
*/
|
|
100 |
|
|
101 |
/*
|
|
102 |
// Override to support rearranging the table view.
|
|
103 |
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
104 |
}
|
|
105 |
*/
|
|
106 |
|
|
107 |
/*
|
|
108 |
// Override to support conditional rearranging of the table view.
|
|
109 |
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
110 |
// Return NO if you do not want the item to be re-orderable.
|
|
111 |
return YES;
|
|
112 |
}
|
|
113 |
*/
|
|
114 |
|
|
115 |
#pragma mark -
|
|
116 |
#pragma mark Table view delegate
|
|
117 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
118 |
|
|
119 |
[detailViewController.navigationController popToRootViewControllerAnimated:NO];
|
|
120 |
|
3312
|
121 |
NSInteger row = [indexPath row];
|
|
122 |
UITableViewController *nextController = [self.controllers objectAtIndex:row];
|
|
123 |
[detailViewController.navigationController pushViewController:nextController animated:YES];
|
3305
|
124 |
}
|
|
125 |
|
|
126 |
|
|
127 |
#pragma mark -
|
|
128 |
#pragma mark Memory management
|
|
129 |
-(void) didReceiveMemoryWarning {
|
|
130 |
// Releases the view if it doesn't have a superview.
|
|
131 |
[super didReceiveMemoryWarning];
|
|
132 |
|
|
133 |
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
134 |
}
|
|
135 |
|
|
136 |
- (void)dealloc {
|
|
137 |
[optionList release];
|
|
138 |
[detailViewController release];
|
|
139 |
[super dealloc];
|
|
140 |
}
|
|
141 |
|
|
142 |
-(IBAction) dismissSplitView {
|
|
143 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
|
|
144 |
}
|
|
145 |
|
|
146 |
@end
|
|
147 |
|