project_files/HedgewarsMobile/Classes/HoldTableViewCell.m
branchios-develop
changeset 12877 00215a7ec5f5
parent 11256 3dc674af7662
equal deleted inserted replaced
12876:2c06b1120749 12877:00215a7ec5f5
    24 @synthesize delegate;
    24 @synthesize delegate;
    25 
    25 
    26 #define SWIPE_DRAG_HORIZ_MIN 10
    26 #define SWIPE_DRAG_HORIZ_MIN 10
    27 #define SWIPE_DRAG_VERT_MAX 40
    27 #define SWIPE_DRAG_VERT_MAX 40
    28 
    28 
    29 -(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    29 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    30     if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
    30     if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
    31         delegate = nil;
    31         delegate = nil;
    32     }
    32     }
    33     return self;
    33     return self;
    34 }
    34 }
    35 
    35 
    36 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    36 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    37     UITouch *touch = [[event allTouches] anyObject];
    37     UITouch *touch = [[event allTouches] anyObject];
    38 
    38 
    39     time = touch.timestamp;
    39     time = touch.timestamp;
    40     [self performSelector:@selector(holdAction) withObject:nil afterDelay:0.25];
    40     [self performSelector:@selector(holdAction) withObject:nil afterDelay:0.25];
    41 
    41 
    42     [super touchesBegan:touches withEvent:event];
    42     [super touchesBegan:touches withEvent:event];
    43 }
    43 }
    44 
    44 
    45 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    45 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    46     UITouch *touch = [[event allTouches] anyObject];
    46     UITouch *touch = [[event allTouches] anyObject];
    47 
    47 
    48     if ( touch.timestamp - time < 0.25 ) {
    48     if ( touch.timestamp - time < 0.25 ) {
    49         [NSObject cancelPreviousPerformRequestsWithTarget:self
    49         [NSObject cancelPreviousPerformRequestsWithTarget:self
    50                                                  selector:@selector(holdAction)
    50                                                  selector:@selector(holdAction)
    53         [super touchesEnded:touches withEvent:event];
    53         [super touchesEnded:touches withEvent:event];
    54     } else
    54     } else
    55         [super touchesCancelled:touches withEvent:event];
    55         [super touchesCancelled:touches withEvent:event];
    56 }
    56 }
    57 
    57 
    58 -(void) holdAction {
    58 - (void)holdAction {
    59     if (self.delegate != nil && [self.delegate respondsToSelector:@selector(holdAction:onTable:)])
    59     if (self.delegate != nil && [self.delegate respondsToSelector:@selector(holdAction:onTable:)])
    60     {
    60     {
    61         UITableView *tableView = [self findTable];
    61         UITableView *tableView = [self findTable];
    62         if (tableView)
    62         if (tableView)
    63         {
    63         {
    64             [self.delegate holdAction:self.textLabel.text onTable:tableView];
    64             [self.delegate holdAction:self.textLabel.text onTable:tableView];
    65         }
    65         }
    66     }
    66     }
    67 }
    67 }
    68 
    68 
    69 -(void) dealloc {
       
    70     self.delegate = nil;
       
    71     [super dealloc];
       
    72 }
       
    73 
       
    74 @end
    69 @end