3305
|
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];
|
3308
|
19 |
|
3305
|
20 |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
3308
|
21 |
NSString *teamsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/Teams/"];
|
3305
|
22 |
|
|
23 |
NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:teamsDirectory
|
|
24 |
error:NULL];
|
|
25 |
self.list = contents;
|
3308
|
26 |
NSLog(@"%@\n%@", teamsDirectory, contents);
|
|
27 |
|
3305
|
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 |
// Override to allow orientations other than the default portrait orientation.
|
|
36 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
37 |
}
|
|
38 |
|
|
39 |
|
|
40 |
#pragma mark -
|
|
41 |
#pragma mark Table view data source
|
|
42 |
|
|
43 |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
44 |
// Return the number of sections.
|
|
45 |
return 1;
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
50 |
// Return the number of rows in the section.
|
|
51 |
return [list count];
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
// Customize the appearance of table view cells.
|
|
56 |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
57 |
|
|
58 |
static NSString *CellIdentifier = @"Cell";
|
|
59 |
|
|
60 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
|
61 |
if (cell == nil) {
|
|
62 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
|
|
63 |
}
|
|
64 |
|
|
65 |
NSUInteger row = [indexPath row];
|
|
66 |
NSString *rowString = [[list objectAtIndex:row] stringByDeletingPathExtension];
|
|
67 |
cell.textLabel.text = rowString;
|
|
68 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
69 |
//cell.imageView.image = [UIImage imageNamed:@"Default.png"];
|
|
70 |
//[rowString release];
|
|
71 |
|
|
72 |
return cell;
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
/*
|
|
77 |
// Override to support conditional editing of the table view.
|
|
78 |
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
79 |
// Return NO if you do not want the specified item to be editable.
|
|
80 |
return YES;
|
|
81 |
}
|
|
82 |
*/
|
|
83 |
|
|
84 |
|
|
85 |
/*
|
|
86 |
// Override to support editing the table view.
|
|
87 |
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
88 |
|
|
89 |
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
|
90 |
// Delete the row from the data source
|
|
91 |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
|
|
92 |
}
|
|
93 |
else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
|
94 |
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
|
|
95 |
}
|
|
96 |
}
|
|
97 |
*/
|
|
98 |
|
|
99 |
|
|
100 |
/*
|
|
101 |
// Override to support rearranging the table view.
|
|
102 |
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
103 |
}
|
|
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 |
|
|
116 |
#pragma mark -
|
|
117 |
#pragma mark Table view delegate
|
|
118 |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
119 |
if (childController == nil) {
|
|
120 |
childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
|
|
121 |
}
|
|
122 |
|
|
123 |
NSInteger row = [indexPath row];
|
|
124 |
NSString *selectedTeam = [[list objectAtIndex:row] stringByDeletingPathExtension];
|
|
125 |
|
|
126 |
childController.teamName = selectedTeam;
|
|
127 |
[self.navigationController pushViewController:childController animated:YES];
|
|
128 |
}
|
|
129 |
|
|
130 |
/*
|
|
131 |
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
|
|
132 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?"
|
|
133 |
message:@"If you're trying to drill down, touch that instead"
|
|
134 |
delegate:nil
|
|
135 |
cancelButtonTitle:@"Won't happen again"
|
|
136 |
otherButtonTitles:nil];
|
|
137 |
[alert show];
|
|
138 |
[alert release];
|
|
139 |
}
|
|
140 |
*/
|
|
141 |
|
|
142 |
#pragma mark -
|
|
143 |
#pragma mark Memory management
|
|
144 |
|
|
145 |
- (void)didReceiveMemoryWarning {
|
|
146 |
// Releases the view if it doesn't have a superview.
|
|
147 |
[super didReceiveMemoryWarning];
|
|
148 |
|
|
149 |
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
150 |
}
|
|
151 |
|
|
152 |
/*
|
|
153 |
- (void)viewDidUnload {
|
|
154 |
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
|
|
155 |
// For example: self.myOutlet = nil;
|
|
156 |
}
|
|
157 |
*/
|
|
158 |
|
|
159 |
- (void)dealloc {
|
|
160 |
[list release];
|
|
161 |
if (nil != childController)
|
|
162 |
[childController release];
|
|
163 |
[super dealloc];
|
|
164 |
}
|
|
165 |
|
|
166 |
|
|
167 |
@end
|
|
168 |
|