cocoaTouch/iPad/TeamSettingsViewController.m
author koda
Fri, 02 Apr 2010 12:38:36 +0000
changeset 3250 d5cd1a617123
child 3251 221c163ad5d9
permissions -rw-r--r--
intial support for team configuration on 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];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    19
    NSArray *array = [[NSArray alloc] initWithObjects:@"Toy Story", @"A Bug's Life", @"Toy Story 2", 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    20
                      @"Monsters, Inc.",@"Finding Nemo", @"The Incredibles", @"Cars", @"Ratatouille", 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    21
                      @"WALL-E", @"Up", @"Toy Story 3", @"Cars 2", @"The Bear and the Bow", @"Newt", nil];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    22
    self.list = array;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    23
    [array release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    24
    // Uncomment the following line to preserve selection between presentations.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    25
    self.clearsSelectionOnViewWillAppear = NO;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    26
    // 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
    27
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    28
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    29
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    30
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    31
    // Override to allow orientations other than the default portrait orientation.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    32
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    33
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    34
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    35
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    36
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    37
#pragma mark Table view data source
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
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    40
    // Return the number of sections.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    41
    return 1;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    42
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    43
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    44
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    45
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    46
    // Return the number of rows in the section.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    47
    return [list count];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    48
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    49
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    50
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    51
// Customize the appearance of table view cells.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    52
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
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
    static NSString *CellIdentifier = @"Cell";
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    55
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    56
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    57
    if (cell == nil) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    58
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    59
    }
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    60
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    61
    NSUInteger row = [indexPath row]; 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    62
    NSString *rowString = [list objectAtIndex:row]; 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    63
    cell.textLabel.text = rowString; 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    64
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    65
    //cell.imageView.image = [UIImage imageNamed:@"Default.png"];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    66
    [rowString release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    67
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    68
    return cell;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    69
}
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
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
// Override to support conditional editing of the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    74
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    75
    // 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
    76
    return YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    77
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    78
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    79
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
// Override to support editing the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    83
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
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
    if (editingStyle == UITableViewCellEditingStyleDelete) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    86
        // Delete the row from the data source
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    87
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    88
    }   
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    89
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    90
        // 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
    91
    }   
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    92
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    93
*/
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
// Override to support rearranging the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    98
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
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
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   101
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
// Override to support conditional rearranging of the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   105
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   106
    // 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
   107
    return YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   108
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   109
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   110
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
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   113
#pragma mark Table view delegate
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
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   116
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   117
    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
   118
                                                    message:@"If you're trying to drill down, touch that instead" 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   119
                                                   delegate:nil
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   120
                                          cancelButtonTitle:@"Won't happen again"
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   121
                                          otherButtonTitles:nil];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   122
    [alert show];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   123
    [alert release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   124
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   125
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   126
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   127
    if (childController == nil) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   128
        childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   129
        //childController = [[DisclosureDetailController alloc] initWithNibName:@"DisclosureDatailController" bundle:nil];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   130
    }
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   131
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   132
    NSInteger row = [indexPath row];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   133
    NSString *selectedMovie = [list objectAtIndex:row];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   134
    NSString *detailMessage = [[NSString alloc] initWithFormat:@"you pressed the button for %@", selectedMovie];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   135
    //self.childController.message = detailMessage;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   136
    childController.title = selectedMovie;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   137
    [detailMessage release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   138
    [self.navigationController pushViewController:childController animated:YES];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   139
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   140
    //[childController viewWillAppear:YES];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   141
}
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
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   144
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   145
#pragma mark Memory management
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   146
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   147
- (void)didReceiveMemoryWarning {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   148
    // Releases the view if it doesn't have a superview.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   149
    [super didReceiveMemoryWarning];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   150
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   151
    // 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
   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
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   155
- (void)viewDidUnload {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   156
    // 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
   157
    // For example: self.myOutlet = nil;
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
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   161
- (void)dealloc {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   162
    [list release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   163
    if (nil != childController)
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   164
        [childController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   165
    [super dealloc];
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
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   169
@end
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   170