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