project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
changeset 4486 2c8e4d859d37
parent 4476 4bf74e158f44
child 4504 8906b2409d97
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m	Wed Dec 08 15:18:08 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m	Wed Dec 08 17:48:33 2010 +0100
@@ -253,19 +253,7 @@
     NSInteger row = [indexPath row];
     NSInteger section = [indexPath section];
 
-    if (section == 0) {
-        NSMutableDictionary *selectedRow = [self.listOfSelectedTeams objectAtIndex:[indexPath row]];
-        UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
-        SquareButtonView *squareButton = (SquareButtonView *)cell.accessoryView;
-
-        NSInteger increaseNumber = [[selectedRow objectForKey:@"number"] intValue] + 1;
-        NSNumber *newNumber = [NSNumber numberWithInt:[self filterNumberOfHogs:increaseNumber]];
-        [squareButton setTitle:[newNumber stringValue] forState:UIControlStateNormal];
-        [selectedRow setObject:newNumber forKey:@"number"];
-
-        cell.imageView.image = [self drawHogsRepeated:[newNumber intValue]];
-        [cell setNeedsLayout];
-    } else {
+    if (section == 1 && [self.listOfTeams count] > row) {
         [self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]];
         [self.listOfTeams removeObjectAtIndex:row];
 
@@ -277,6 +265,18 @@
         [aTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
         [aTableView endUpdates];
     }
+    if (section == 0 && [self.listOfSelectedTeams count] > row) {
+        NSMutableDictionary *selectedRow = [self.listOfSelectedTeams objectAtIndex:row];
+        UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
+        SquareButtonView *squareButton = (SquareButtonView *)cell.accessoryView;
+
+        NSInteger increaseNumber = [[selectedRow objectForKey:@"number"] intValue] + 1;
+        NSNumber *newNumber = [NSNumber numberWithInt:[self filterNumberOfHogs:increaseNumber]];
+        [squareButton setTitle:[newNumber stringValue] forState:UIControlStateNormal];
+        [selectedRow setObject:newNumber forKey:@"number"];
+
+        cell.imageView.image = [self drawHogsRepeated:[newNumber intValue]];
+    }
 }
 
 -(void) holdAction:(NSString *)content {