cocoaTouch/iPad/TeamSettingsViewController.m
changeset 3251 221c163ad5d9
parent 3250 d5cd1a617123
child 3253 b0b1b1310b7e
equal deleted inserted replaced
3250:d5cd1a617123 3251:221c163ad5d9
    14 
    14 
    15 #pragma mark -
    15 #pragma mark -
    16 #pragma mark View lifecycle
    16 #pragma mark View lifecycle
    17 - (void)viewDidLoad {
    17 - (void)viewDidLoad {
    18     [super viewDidLoad];
    18     [super viewDidLoad];
    19     NSArray *array = [[NSArray alloc] initWithObjects:@"Toy Story", @"A Bug's Life", @"Toy Story 2", 
    19     
    20                       @"Monsters, Inc.",@"Finding Nemo", @"The Incredibles", @"Cars", @"Ratatouille", 
    20     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    21                       @"WALL-E", @"Up", @"Toy Story 3", @"Cars 2", @"The Bear and the Bow", @"Newt", nil];
    21     NSString *teamsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"Teams/"];
    22     self.list = array;
    22     
    23     [array release];
    23     NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:teamsDirectory
       
    24                                                                             error:NULL];
       
    25     //NSArray *array = [[NSArray alloc] initWithObjects:@"Toy Story", @"A Bug's Life", @"Toy Story 2", 
       
    26     //                  @"Monsters, Inc.",@"Finding Nemo", @"The Incredibles", @"Cars", @"Ratatouille", 
       
    27     //                  @"WALL-E", @"Up", @"Toy Story 3", @"Cars 2", @"The Bear and the Bow", @"Newt", nil];
       
    28     self.list = contents;
       
    29    
    24     // Uncomment the following line to preserve selection between presentations.
    30     // Uncomment the following line to preserve selection between presentations.
    25     self.clearsSelectionOnViewWillAppear = NO;
    31     self.clearsSelectionOnViewWillAppear = NO;
    26     // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    32     // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    27     // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    33     // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    28 }
    34 }
    57     if (cell == nil) {
    63     if (cell == nil) {
    58         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    64         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    59     }
    65     }
    60     
    66     
    61     NSUInteger row = [indexPath row]; 
    67     NSUInteger row = [indexPath row]; 
    62     NSString *rowString = [list objectAtIndex:row]; 
    68     NSString *rowString = [[list objectAtIndex:row] stringByDeletingPathExtension]; 
    63     cell.textLabel.text = rowString; 
    69     cell.textLabel.text = rowString; 
    64     cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    70     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    65     //cell.imageView.image = [UIImage imageNamed:@"Default.png"];
    71     //cell.imageView.image = [UIImage imageNamed:@"Default.png"];
    66     [rowString release];
    72     //[rowString release];
    67     
    73     
    68     return cell;
    74     return cell;
    69 }
    75 }
    70 
    76 
    71 
    77 
   111 
   117 
   112 #pragma mark -
   118 #pragma mark -
   113 #pragma mark Table view delegate
   119 #pragma mark Table view delegate
   114 
   120 
   115 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   121 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
       
   122  if (childController == nil) {
       
   123         childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
       
   124     }
       
   125     
       
   126     NSInteger row = [indexPath row];
       
   127     NSString *selectedMovie = [[list objectAtIndex:row] stringByDeletingPathExtension];
       
   128     NSString *detailMessage = [[NSString alloc] initWithFormat:@"you pressed the button for %@", selectedMovie];
   116 
   129 
       
   130     childController.title = selectedMovie;
       
   131     [detailMessage release];
       
   132     [self.navigationController pushViewController:childController animated:YES];
       
   133 
       
   134 }
       
   135 
       
   136 /*
       
   137 -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
   117     UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?" 
   138     UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?" 
   118                                                     message:@"If you're trying to drill down, touch that instead" 
   139                                                     message:@"If you're trying to drill down, touch that instead" 
   119                                                    delegate:nil
   140                                                    delegate:nil
   120                                           cancelButtonTitle:@"Won't happen again"
   141                                           cancelButtonTitle:@"Won't happen again"
   121                                           otherButtonTitles:nil];
   142                                           otherButtonTitles:nil];
   122     [alert show];
   143     [alert show];
   123     [alert release];
   144     [alert release];
   124 }
   145 }
   125 
   146 */
   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 
   147 
   144 #pragma mark -
   148 #pragma mark -
   145 #pragma mark Memory management
   149 #pragma mark Memory management
   146 
   150 
   147 - (void)didReceiveMemoryWarning {
   151 - (void)didReceiveMemoryWarning {