author | nemo |
Fri, 02 Apr 2010 16:04:37 +0000 | |
changeset 3261 | fa7086253e83 |
parent 3250 | d5cd1a617123 |
permissions | -rw-r--r-- |
3113 | 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" |
|
11 |
||
12 |
@implementation MasterViewController |
|
13 |
@synthesize detailViewController, optionList; |
|
14 |
||
15 |
#pragma mark - |
|
16 |
#pragma mark View lifecycle |
|
17 |
||
18 |
||
19 |
- (void)viewDidLoad { |
|
20 |
[super viewDidLoad]; |
|
21 |
optionList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), |
|
22 |
NSLocalizedString(@"Teams",@""), |
|
23 |
NSLocalizedString(@"Weapons",@""), |
|
24 |
NSLocalizedString(@"Schemes",@""), |
|
25 |
nil]; |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
26 |
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:0 target:self action:@selector(dismissSplitView)]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
27 |
|
3113 | 28 |
// Uncomment the following line to preserve selection between presentations. |
29 |
//self.clearsSelectionOnViewWillAppear = NO; |
|
30 |
// Uncomment the following line to display an Edit button in the navigation bar for this view controller. |
|
31 |
//self.navigationItem.rightBarButtonItem = self.editButtonItem; |
|
32 |
} |
|
33 |
||
34 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
35 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
|
36 |
} |
|
37 |
||
38 |
||
39 |
#pragma mark - |
|
40 |
#pragma mark Table view data source |
|
41 |
||
42 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
43 |
return 1; |
|
44 |
} |
|
45 |
||
46 |
||
47 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
48 |
return [optionList count]; |
|
49 |
} |
|
50 |
||
51 |
||
52 |
// Customize the appearance of table view cells. |
|
53 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
54 |
static NSString *CellIdentifier = @"Cell"; |
|
55 |
||
56 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
57 |
if (cell == nil) { |
|
58 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
|
59 |
cell.textLabel.text = [optionList objectAtIndex:[indexPath row]]; |
|
60 |
} |
|
61 |
||
62 |
return cell; |
|
63 |
} |
|
64 |
||
65 |
/* |
|
66 |
// Override to support editing the table view. |
|
67 |
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { |
|
68 |
||
69 |
if (editingStyle == UITableViewCellEditingStyleDelete) { |
|
70 |
// Delete the row from the data source |
|
71 |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; |
|
72 |
} |
|
73 |
else if (editingStyle == UITableViewCellEditingStyleInsert) { |
|
74 |
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view |
|
75 |
} |
|
76 |
} |
|
77 |
*/ |
|
78 |
||
79 |
/* |
|
80 |
// Override to support rearranging the table view. |
|
81 |
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { |
|
82 |
} |
|
83 |
*/ |
|
84 |
||
85 |
/* |
|
86 |
// Override to support conditional rearranging of the table view. |
|
87 |
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { |
|
88 |
// Return NO if you do not want the item to be re-orderable. |
|
89 |
return YES; |
|
90 |
} |
|
91 |
*/ |
|
92 |
||
93 |
#pragma mark - |
|
94 |
#pragma mark Table view delegate |
|
95 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
96 |
// Navigation logic may go here. Create and push another view controller. |
|
97 |
/* |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
98 |
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
99 |
// Pass the selected object to the new view controller. |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
100 |
[self.navigationController pushViewController:detailViewController animated:YES]; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
101 |
[detailViewController release]; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
102 |
*/ |
3113 | 103 |
detailViewController.detailItem = [[NSString alloc] initWithFormat:@"%d", [indexPath row]]; |
104 |
} |
|
105 |
||
106 |
||
107 |
#pragma mark - |
|
108 |
#pragma mark Memory management |
|
109 |
-(void) didReceiveMemoryWarning { |
|
110 |
// Releases the view if it doesn't have a superview. |
|
111 |
[super didReceiveMemoryWarning]; |
|
112 |
||
113 |
// Relinquish ownership any cached data, images, etc that aren't in use. |
|
114 |
} |
|
115 |
||
116 |
- (void)dealloc { |
|
117 |
[optionList release]; |
|
118 |
[detailViewController release]; |
|
119 |
[super dealloc]; |
|
120 |
} |
|
121 |
||
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
122 |
-(IBAction) dismissSplitView { |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
123 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
124 |
} |
3113 | 125 |
|
126 |
@end |
|
127 |