cocoaTouch/iPad/TeamSettingsViewController.m
changeset 3250 d5cd1a617123
child 3251 221c163ad5d9
equal deleted inserted replaced
3249:74a506c9d71b 3250:d5cd1a617123
       
     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];
       
    19     NSArray *array = [[NSArray alloc] initWithObjects:@"Toy Story", @"A Bug's Life", @"Toy Story 2", 
       
    20                       @"Monsters, Inc.",@"Finding Nemo", @"The Incredibles", @"Cars", @"Ratatouille", 
       
    21                       @"WALL-E", @"Up", @"Toy Story 3", @"Cars 2", @"The Bear and the Bow", @"Newt", nil];
       
    22     self.list = array;
       
    23     [array release];
       
    24     // Uncomment the following line to preserve selection between presentations.
       
    25     self.clearsSelectionOnViewWillAppear = NO;
       
    26     // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
       
    27     // self.navigationItem.rightBarButtonItem = self.editButtonItem;
       
    28 }
       
    29 
       
    30 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
       
    31     // Override to allow orientations other than the default portrait orientation.
       
    32     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
       
    33 }
       
    34 
       
    35 
       
    36 #pragma mark -
       
    37 #pragma mark Table view data source
       
    38 
       
    39 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
       
    40     // Return the number of sections.
       
    41     return 1;
       
    42 }
       
    43 
       
    44 
       
    45 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
       
    46     // Return the number of rows in the section.
       
    47     return [list count];
       
    48 }
       
    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]; 
       
    63     cell.textLabel.text = rowString; 
       
    64     cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
       
    65     //cell.imageView.image = [UIImage imageNamed:@"Default.png"];
       
    66     [rowString release];
       
    67     
       
    68     return cell;
       
    69 }
       
    70 
       
    71 
       
    72 /*
       
    73 // Override to support conditional editing of the table view.
       
    74 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
       
    75     // Return NO if you do not want the specified item to be editable.
       
    76     return YES;
       
    77 }
       
    78 */
       
    79 
       
    80 
       
    81 /*
       
    82 // Override to support editing the table view.
       
    83 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
       
    84     
       
    85     if (editingStyle == UITableViewCellEditingStyleDelete) {
       
    86         // Delete the row from the data source
       
    87         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
       
    88     }   
       
    89     else if (editingStyle == UITableViewCellEditingStyleInsert) {
       
    90         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
       
    91     }   
       
    92 }
       
    93 */
       
    94 
       
    95 
       
    96 /*
       
    97 // Override to support rearranging the table view.
       
    98 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
       
    99 }
       
   100 */
       
   101 
       
   102 
       
   103 /*
       
   104 // Override to support conditional rearranging of the table view.
       
   105 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
       
   106     // Return NO if you do not want the item to be re-orderable.
       
   107     return YES;
       
   108 }
       
   109 */
       
   110 
       
   111 
       
   112 #pragma mark -
       
   113 #pragma mark Table view delegate
       
   114 
       
   115 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
       
   116 
       
   117     UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?" 
       
   118                                                     message:@"If you're trying to drill down, touch that instead" 
       
   119                                                    delegate:nil
       
   120                                           cancelButtonTitle:@"Won't happen again"
       
   121                                           otherButtonTitles:nil];
       
   122     [alert show];
       
   123     [alert release];
       
   124 }
       
   125 
       
   126 -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
       
   127     if (childController == nil) {
       
   128         childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
       
   129         //childController = [[DisclosureDetailController alloc] initWithNibName:@"DisclosureDatailController" bundle:nil];
       
   130     }
       
   131     
       
   132     NSInteger row = [indexPath row];
       
   133     NSString *selectedMovie = [list objectAtIndex:row];
       
   134     NSString *detailMessage = [[NSString alloc] initWithFormat:@"you pressed the button for %@", selectedMovie];
       
   135     //self.childController.message = detailMessage;
       
   136     childController.title = selectedMovie;
       
   137     [detailMessage release];
       
   138     [self.navigationController pushViewController:childController animated:YES];
       
   139 
       
   140     //[childController viewWillAppear:YES];
       
   141 }
       
   142 
       
   143 
       
   144 #pragma mark -
       
   145 #pragma mark Memory management
       
   146 
       
   147 - (void)didReceiveMemoryWarning {
       
   148     // Releases the view if it doesn't have a superview.
       
   149     [super didReceiveMemoryWarning];
       
   150     
       
   151     // Relinquish ownership any cached data, images, etc that aren't in use.
       
   152 }
       
   153 
       
   154 /*
       
   155 - (void)viewDidUnload {
       
   156     // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
       
   157     // For example: self.myOutlet = nil;
       
   158 }
       
   159 */
       
   160 
       
   161 - (void)dealloc {
       
   162     [list release];
       
   163     if (nil != childController)
       
   164         [childController release];
       
   165     [super dealloc];
       
   166 }
       
   167 
       
   168 
       
   169 @end
       
   170