3250
|
1 |
//
|
|
2 |
// TeamSettingsViewController.m
|
|
3 |
// HedgewarsMobile
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 02/04/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "TeamSettingsViewController.h"
|
|
10 |
#import "SingleTeamViewController.h"
|
|
11 |
|
|
12 |
@implementation TeamSettingsViewController
|
|
13 |
@synthesize list;
|
|
14 |
|
|
15 |
#pragma mark -
|
|
16 |
#pragma mark View lifecycle
|
|
17 |
- (void)viewDidLoad {
|
|
18 |
[super viewDidLoad];
|
3251
|
19 |
|
|
20 |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
21 |
NSString *teamsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"Teams/"];
|
|
22 |
|
|
23 |
NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:teamsDirectory
|
|
24 |
error:NULL];
|
|
25 |
//NSArray *array = [[NSArray alloc] initWithObjects:@"Toy Story", @"A Bug's Life", @"Toy Story 2",
|
|
26 |
// @"Monsters, Inc.",@"Finding Nemo", @"The Incredibles", @"Cars", @"Ratatouille",
|
|
27 |
// @"WALL-E", @"Up", @"Toy Story 3", @"Cars 2", @"The Bear and the Bow", @"Newt", nil];
|
|
28 |
self.list = contents;
|
|
29 |
|
3250
|
30 |
// Uncomment the following line to preserve selection between presentations.
|
|
31 |
self.clearsSelectionOnViewWillAppear = NO;
|
|
32 |
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
|
|
33 |
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
|
34 |
}
|
|
35 |
|
|
36 |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
37 |
// Override to allow orientations other than the default portrait orientation.
|
|
38 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
39 |
}
|
|
40 |
|
|
41 |
|
|
42 |
#pragma mark -
|
|
43 |
#pragma mark Table view data source
|
|
44 |
|
|
45 |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
46 |
// Return the number of sections.
|
|
47 |
return 1;
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
52 |
// Return the number of rows in the section.
|
|
53 |
return [list count];
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
// Customize the appearance of table view cells.
|
|
58 |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
59 |
|
|
60 |
static NSString *CellIdentifier = @"Cell";
|
|
61 |
|
|
62 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
|
63 |
if (cell == nil) {
|
|
64 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
|
|
65 |
}
|
|
66 |
|
|
67 |
NSUInteger row = [indexPath row];
|
3251
|
68 |
NSString *rowString = [[list objectAtIndex:row] stringByDeletingPathExtension];
|
3250
|
69 |
cell.textLabel.text = rowString;
|
3251
|
70 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
3250
|
71 |
//cell.imageView.image = [UIImage imageNamed:@"Default.png"];
|
3251
|
72 |
//[rowString release];
|
3250
|
73 |
|
|
74 |
return cell;
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
/*
|
|
79 |
// Override to support conditional editing of the table view.
|
|
80 |
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
81 |
// Return NO if you do not want the specified item to be editable.
|
|
82 |
return YES;
|
|
83 |
}
|
|
84 |
*/
|
|
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 |
/*
|
|
103 |
// Override to support rearranging the table view.
|
|
104 |
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
105 |
}
|
|
106 |
*/
|
|
107 |
|
|
108 |
|
|
109 |
/*
|
|
110 |
// Override to support conditional rearranging of the table view.
|
|
111 |
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
112 |
// Return NO if you do not want the item to be re-orderable.
|
|
113 |
return YES;
|
|
114 |
}
|
|
115 |
*/
|
|
116 |
|
|
117 |
|
|
118 |
#pragma mark -
|
|
119 |
#pragma mark Table view delegate
|
|
120 |
|
|
121 |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
3251
|
122 |
if (childController == nil) {
|
|
123 |
childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
|
|
124 |
}
|
|
125 |
|
|
126 |
NSInteger row = [indexPath row];
|
|
127 |
NSString *selectedMovie = [[list objectAtIndex:row] stringByDeletingPathExtension];
|
|
128 |
NSString *detailMessage = [[NSString alloc] initWithFormat:@"you pressed the button for %@", selectedMovie];
|
3250
|
129 |
|
3251
|
130 |
childController.title = selectedMovie;
|
|
131 |
[detailMessage release];
|
|
132 |
[self.navigationController pushViewController:childController animated:YES];
|
|
133 |
|
|
134 |
}
|
|
135 |
|
|
136 |
/*
|
|
137 |
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
|
3250
|
138 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?"
|
|
139 |
message:@"If you're trying to drill down, touch that instead"
|
|
140 |
delegate:nil
|
|
141 |
cancelButtonTitle:@"Won't happen again"
|
|
142 |
otherButtonTitles:nil];
|
|
143 |
[alert show];
|
|
144 |
[alert release];
|
|
145 |
}
|
3251
|
146 |
*/
|
3250
|
147 |
|
|
148 |
#pragma mark -
|
|
149 |
#pragma mark Memory management
|
|
150 |
|
|
151 |
- (void)didReceiveMemoryWarning {
|
|
152 |
// Releases the view if it doesn't have a superview.
|
|
153 |
[super didReceiveMemoryWarning];
|
|
154 |
|
|
155 |
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
156 |
}
|
|
157 |
|
|
158 |
/*
|
|
159 |
- (void)viewDidUnload {
|
|
160 |
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
|
|
161 |
// For example: self.myOutlet = nil;
|
|
162 |
}
|
|
163 |
*/
|
|
164 |
|
|
165 |
- (void)dealloc {
|
|
166 |
[list release];
|
|
167 |
if (nil != childController)
|
|
168 |
[childController release];
|
|
169 |
[super dealloc];
|
|
170 |
}
|
|
171 |
|
|
172 |
|
|
173 |
@end
|
|
174 |
|