# HG changeset patch # User koda # Date 1291826913 -3600 # Node ID 2c8e4d859d379718d56f84fcd4953f19694e6530 # Parent 85695e3d2623451d17440345169103a37eda3817 fix crasher (somehow, might be glitchy) diff -r 85695e3d2623 -r 2c8e4d859d37 project_files/HedgewarsMobile/Classes/HoldTableViewCell.h --- a/project_files/HedgewarsMobile/Classes/HoldTableViewCell.h Wed Dec 08 15:18:08 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/HoldTableViewCell.h Wed Dec 08 17:48:33 2010 +0100 @@ -29,6 +29,7 @@ @interface HoldTableViewCell : UITableViewCell { id delegate; + NSTimeInterval time; } @property (nonatomic,assign) id delegate; diff -r 85695e3d2623 -r 2c8e4d859d37 project_files/HedgewarsMobile/Classes/HoldTableViewCell.m --- a/project_files/HedgewarsMobile/Classes/HoldTableViewCell.m Wed Dec 08 15:18:08 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/HoldTableViewCell.m Wed Dec 08 17:48:33 2010 +0100 @@ -18,8 +18,6 @@ * File created on 03/07/2010. */ -//http://devblog.wm-innovations.com/2010/03/30/custom-swipe-uitableviewcell/ - #import "HoldTableViewCell.h" #import "CGPointUtils.h" @@ -38,17 +36,25 @@ } -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - [self performSelector:@selector(holdAction) withObject:nil afterDelay:0.4]; + UITouch *touch = [[event allTouches] anyObject]; + + time = touch.timestamp; + [self performSelector:@selector(holdAction) withObject:nil afterDelay:0.25]; [super touchesBegan:touches withEvent:event]; } -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - [NSObject cancelPreviousPerformRequestsWithTarget:self - selector:@selector(holdAction) - object:nil]; - - [super touchesEnded:touches withEvent:event]; + UITouch *touch = [[event allTouches] anyObject]; + + if ( touch.timestamp - time < 0.25 ) { + [NSObject cancelPreviousPerformRequestsWithTarget:self + selector:@selector(holdAction) + object:nil]; + + [super touchesEnded:touches withEvent:event]; + } else + [super touchesCancelled:touches withEvent:event]; } -(void) holdAction { diff -r 85695e3d2623 -r 2c8e4d859d37 project_files/HedgewarsMobile/Classes/TeamConfigViewController.m --- 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 {