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;
|
3315
|
26 |
//NSLog(@"%@\n%@", teamsDirectory, contents);
|
3308
|
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 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
36 |
}
|
|
37 |
|
|
38 |
|
|
39 |
#pragma mark -
|
|
40 |
#pragma mark Table view data source
|
|
41 |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
42 |
// Return the number of sections.
|
|
43 |
return 1;
|
|
44 |
}
|
|
45 |
|
|
46 |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
47 |
// Return the number of rows in the section.
|
|
48 |
return [list count];
|
|
49 |
}
|
|
50 |
|
|
51 |
// Customize the appearance of table view cells.
|
|
52 |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
53 |
|
|
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 |
}
|
|
60 |
|
|
61 |
NSUInteger row = [indexPath row];
|
|
62 |
NSString *rowString = [[list objectAtIndex:row] stringByDeletingPathExtension];
|
|
63 |
cell.textLabel.text = rowString;
|
|
64 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
65 |
|
|
66 |
return cell;
|
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
/*
|
|
71 |
// Override to support conditional editing of the table view.
|
|
72 |
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
73 |
// Return NO if you do not want the specified item to be editable.
|
|
74 |
return YES;
|
|
75 |
}
|
|
76 |
*/
|
|
77 |
|
|
78 |
|
|
79 |
/*
|
|
80 |
// Override to support editing the table view.
|
|
81 |
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
82 |
|
|
83 |
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
|
84 |
// Delete the row from the data source
|
|
85 |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
|
|
86 |
}
|
|
87 |
else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
|
88 |
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
|
|
89 |
}
|
|
90 |
}
|
|
91 |
*/
|
|
92 |
|
|
93 |
|
|
94 |
/*
|
|
95 |
// Override to support rearranging the table view.
|
|
96 |
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
97 |
}
|
|
98 |
*/
|
|
99 |
|
|
100 |
|
|
101 |
/*
|
|
102 |
// Override to support conditional rearranging of the table view.
|
|
103 |
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
104 |
// Return NO if you do not want the item to be re-orderable.
|
|
105 |
return YES;
|
|
106 |
}
|
|
107 |
*/
|
|
108 |
|
|
109 |
|
|
110 |
#pragma mark -
|
|
111 |
#pragma mark Table view delegate
|
|
112 |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
113 |
if (childController == nil) {
|
|
114 |
childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
|
|
115 |
}
|
|
116 |
|
|
117 |
NSInteger row = [indexPath row];
|
|
118 |
NSString *selectedTeam = [[list objectAtIndex:row] stringByDeletingPathExtension];
|
|
119 |
|
3315
|
120 |
childController.title = selectedTeam;
|
3305
|
121 |
[self.navigationController pushViewController:childController animated:YES];
|
|
122 |
}
|
|
123 |
|
|
124 |
/*
|
|
125 |
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
|
|
126 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?"
|
|
127 |
message:@"If you're trying to drill down, touch that instead"
|
|
128 |
delegate:nil
|
|
129 |
cancelButtonTitle:@"Won't happen again"
|
|
130 |
otherButtonTitles:nil];
|
|
131 |
[alert show];
|
|
132 |
[alert release];
|
|
133 |
}
|
|
134 |
*/
|
|
135 |
|
|
136 |
#pragma mark -
|
|
137 |
#pragma mark Memory management
|
|
138 |
|
|
139 |
- (void)didReceiveMemoryWarning {
|
|
140 |
// Releases the view if it doesn't have a superview.
|
|
141 |
[super didReceiveMemoryWarning];
|
|
142 |
|
|
143 |
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
144 |
}
|
|
145 |
|
|
146 |
- (void)viewDidUnload {
|
3315
|
147 |
self.list = nil;
|
3305
|
148 |
}
|
3315
|
149 |
|
3305
|
150 |
|
|
151 |
- (void)dealloc {
|
|
152 |
[list release];
|
|
153 |
if (nil != childController)
|
|
154 |
[childController release];
|
|
155 |
[super dealloc];
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
@end
|
|
160 |
|