23 #pragma mark View lifecycle |
23 #pragma mark View lifecycle |
24 // add an edit button |
24 // add an edit button |
25 -(void) viewDidLoad { |
25 -(void) viewDidLoad { |
26 [super viewDidLoad]; |
26 [super viewDidLoad]; |
27 |
27 |
28 UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the team navigation") |
28 UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the team panel") |
29 style:UIBarButtonItemStyleBordered |
29 style:UIBarButtonItemStyleBordered |
30 target:self |
30 target:self |
31 action:@selector(toggleEdit:)]; |
31 action:@selector(toggleEdit:)]; |
32 self.navigationItem.rightBarButtonItem = editButton; |
32 self.navigationItem.rightBarButtonItem = editButton; |
33 [editButton release]; |
33 [editButton release]; |
49 -(void) toggleEdit:(id) sender { |
49 -(void) toggleEdit:(id) sender { |
50 BOOL isEditing = self.tableView.editing; |
50 BOOL isEditing = self.tableView.editing; |
51 [self.tableView setEditing:!isEditing animated:YES]; |
51 [self.tableView setEditing:!isEditing animated:YES]; |
52 |
52 |
53 if (isEditing) { |
53 if (isEditing) { |
54 [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the team navigation")]; |
54 [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the team panel")]; |
55 [self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered]; |
55 [self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered]; |
56 self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem; |
56 self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem; |
57 } else { |
57 } else { |
58 [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Done",@"from the team navigation")]; |
58 [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Done",@"from the team panel")]; |
59 [self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone]; |
59 [self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone]; |
60 UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Add",@"from the team navigation") |
60 UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Add",@"from the team panel") |
61 style:UIBarButtonItemStyleBordered |
61 style:UIBarButtonItemStyleBordered |
62 target:self |
62 target:self |
63 action:@selector(addTeam:)]; |
63 action:@selector(addTeam:)]; |
64 self.navigationItem.leftBarButtonItem = addButton; |
64 self.navigationItem.leftBarButtonItem = addButton; |
65 [addButton release]; |
65 [addButton release]; |
86 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
86 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
87 return 1; |
87 return 1; |
88 } |
88 } |
89 |
89 |
90 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
90 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
91 return [listOfTeams count]; |
91 return [self.listOfTeams count]; |
92 } |
92 } |
93 |
93 |
94 // Customize the appearance of table view cells. |
94 // Customize the appearance of table view cells. |
95 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
95 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
96 static NSString *CellIdentifier = @"Cell"; |
96 static NSString *CellIdentifier = @"Cell"; |
99 if (cell == nil) { |
99 if (cell == nil) { |
100 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
100 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
101 } |
101 } |
102 |
102 |
103 NSUInteger row = [indexPath row]; |
103 NSUInteger row = [indexPath row]; |
104 NSString *rowString = [[listOfTeams objectAtIndex:row] stringByDeletingPathExtension]; |
104 NSString *rowString = [[self.listOfTeams objectAtIndex:row] stringByDeletingPathExtension]; |
105 cell.textLabel.text = rowString; |
105 cell.textLabel.text = rowString; |
106 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
106 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
107 |
107 |
108 return cell; |
108 return cell; |
109 } |
109 } |
118 |
118 |
119 [self.listOfTeams removeObjectAtIndex:row]; |
119 [self.listOfTeams removeObjectAtIndex:row]; |
120 [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; |
120 [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; |
121 } |
121 } |
122 |
122 |
123 /* |
|
124 // Override to support editing the table view. |
|
125 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { |
|
126 |
|
127 if (editingStyle == UITableViewCellEditingStyleDelete) { |
|
128 // Delete the row from the data source |
|
129 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; |
|
130 } |
|
131 else if (editingStyle == UITableViewCellEditingStyleInsert) { |
|
132 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view |
|
133 } |
|
134 } |
|
135 */ |
|
136 |
|
137 |
123 |
138 #pragma mark - |
124 #pragma mark - |
139 #pragma mark Table view delegate |
125 #pragma mark Table view delegate |
140 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
126 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
141 if (childController == nil) { |
127 if (childController == nil) { |
142 childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
128 childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
143 } |
129 } |
144 |
130 |
145 NSInteger row = [indexPath row]; |
131 NSInteger row = [indexPath row]; |
146 NSString *selectedTeamFile = [listOfTeams objectAtIndex:row]; |
132 NSString *selectedTeamFile = [listOfTeams objectAtIndex:row]; |
147 NSLog(@"%@",selectedTeamFile); |
|
148 |
133 |
149 // this must be set so childController can load the correct plist |
134 // this must be set so childController can load the correct plist |
150 childController.title = [selectedTeamFile stringByDeletingPathExtension]; |
135 childController.title = [selectedTeamFile stringByDeletingPathExtension]; |
151 [childController.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
136 [childController.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
152 |
137 |