cocoaTouch/iPad/TeamSettingsViewController.m
author koda
Fri, 02 Apr 2010 15:30:54 +0000
changeset 3253 b0b1b1310b7e
parent 3251 221c163ad5d9
child 3270 9bd8fb1707b9
permissions -rw-r--r--
display team contents in the ifrontend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     1
//
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     2
//  TeamSettingsViewController.m
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     3
//  HedgewarsMobile
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     4
//
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     5
//  Created by Vittorio on 02/04/10.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     7
//
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     8
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     9
#import "TeamSettingsViewController.h"
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    10
#import "SingleTeamViewController.h"
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    11
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    12
@implementation TeamSettingsViewController
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    13
@synthesize list;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    14
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    15
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    16
#pragma mark View lifecycle
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    17
- (void)viewDidLoad {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    18
    [super viewDidLoad];
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    19
    
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    20
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    21
    NSString *teamsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"Teams/"];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    22
    
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    23
    NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:teamsDirectory
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    24
                                                                            error:NULL];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    25
    self.list = contents;
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    26
   
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    27
    // Uncomment the following line to preserve selection between presentations.
3253
b0b1b1310b7e display team contents in the ifrontend
koda
parents: 3251
diff changeset
    28
    // self.clearsSelectionOnViewWillAppear = NO;
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    29
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    30
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    31
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    32
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    33
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    34
    // Override to allow orientations other than the default portrait orientation.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    35
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    36
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    37
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    38
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    39
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    40
#pragma mark Table view data source
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    41
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    42
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    43
    // Return the number of sections.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    44
    return 1;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    45
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    46
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    47
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    48
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    49
    // Return the number of rows in the section.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    50
    return [list count];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    51
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    52
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    53
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    54
// Customize the appearance of table view cells.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    55
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    56
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    57
    static NSString *CellIdentifier = @"Cell";
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    58
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    59
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    60
    if (cell == nil) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    61
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    62
    }
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    63
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    64
    NSUInteger row = [indexPath row]; 
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    65
    NSString *rowString = [[list objectAtIndex:row] stringByDeletingPathExtension]; 
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    66
    cell.textLabel.text = rowString; 
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    67
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    68
    //cell.imageView.image = [UIImage imageNamed:@"Default.png"];
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    69
    //[rowString release];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    70
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    71
    return cell;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    72
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    73
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    74
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    75
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    76
// Override to support conditional editing of the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    77
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    78
    // Return NO if you do not want the specified item to be editable.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    79
    return YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    80
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    81
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    82
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    83
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    84
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    85
// Override to support editing the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    86
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    87
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    88
    if (editingStyle == UITableViewCellEditingStyleDelete) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    89
        // Delete the row from the data source
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    90
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    91
    }   
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    92
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    93
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    94
    }   
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    95
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    96
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    97
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    98
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    99
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   100
// Override to support rearranging the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   101
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   102
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   103
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   104
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   105
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   106
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   107
// Override to support conditional rearranging of the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   108
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   109
    // Return NO if you do not want the item to be re-orderable.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   110
    return YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   111
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   112
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   113
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   114
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   115
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   116
#pragma mark Table view delegate
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   117
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   118
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   119
 if (childController == nil) {
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   120
        childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   121
    }
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   122
    
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   123
    NSInteger row = [indexPath row];
3253
b0b1b1310b7e display team contents in the ifrontend
koda
parents: 3251
diff changeset
   124
    NSString *selectedTeam = [[list objectAtIndex:row] stringByDeletingPathExtension];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   125
3253
b0b1b1310b7e display team contents in the ifrontend
koda
parents: 3251
diff changeset
   126
    childController.title = selectedTeam;
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   127
    [self.navigationController pushViewController:childController animated:YES];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   128
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   129
}
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   130
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   131
/*
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   132
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   133
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?" 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   134
                                                    message:@"If you're trying to drill down, touch that instead" 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   135
                                                   delegate:nil
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   136
                                          cancelButtonTitle:@"Won't happen again"
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   137
                                          otherButtonTitles:nil];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   138
    [alert show];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   139
    [alert release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   140
}
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   141
*/
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   142
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   143
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   144
#pragma mark Memory management
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   145
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   146
- (void)didReceiveMemoryWarning {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   147
    // Releases the view if it doesn't have a superview.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   148
    [super didReceiveMemoryWarning];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   149
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   150
    // Relinquish ownership any cached data, images, etc that aren't in use.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   151
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   152
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   153
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   154
- (void)viewDidUnload {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   155
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   156
    // For example: self.myOutlet = nil;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   157
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   158
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   159
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   160
- (void)dealloc {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   161
    [list release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   162
    if (nil != childController)
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   163
        [childController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   164
    [super dealloc];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   165
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   166
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   167
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   168
@end
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   169