equal
deleted
inserted
replaced
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 * |
17 * |
18 * File created on 03/07/2010. |
18 * File created on 03/07/2010. |
19 */ |
19 */ |
20 |
20 |
21 //http://devblog.wm-innovations.com/2010/03/30/custom-swipe-uitableviewcell/ |
|
22 |
|
23 |
21 |
24 #import "HoldTableViewCell.h" |
22 #import "HoldTableViewCell.h" |
25 #import "CGPointUtils.h" |
23 #import "CGPointUtils.h" |
26 |
24 |
27 @implementation HoldTableViewCell |
25 @implementation HoldTableViewCell |
36 } |
34 } |
37 return self; |
35 return self; |
38 } |
36 } |
39 |
37 |
40 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
38 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
41 [self performSelector:@selector(holdAction) withObject:nil afterDelay:0.4]; |
39 UITouch *touch = [[event allTouches] anyObject]; |
|
40 |
|
41 time = touch.timestamp; |
|
42 [self performSelector:@selector(holdAction) withObject:nil afterDelay:0.25]; |
42 |
43 |
43 [super touchesBegan:touches withEvent:event]; |
44 [super touchesBegan:touches withEvent:event]; |
44 } |
45 } |
45 |
46 |
46 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
47 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
47 [NSObject cancelPreviousPerformRequestsWithTarget:self |
48 UITouch *touch = [[event allTouches] anyObject]; |
48 selector:@selector(holdAction) |
49 |
49 object:nil]; |
50 if ( touch.timestamp - time < 0.25 ) { |
50 |
51 [NSObject cancelPreviousPerformRequestsWithTarget:self |
51 [super touchesEnded:touches withEvent:event]; |
52 selector:@selector(holdAction) |
|
53 object:nil]; |
|
54 |
|
55 [super touchesEnded:touches withEvent:event]; |
|
56 } else |
|
57 [super touchesCancelled:touches withEvent:event]; |
52 } |
58 } |
53 |
59 |
54 -(void) holdAction { |
60 -(void) holdAction { |
55 if (self.delegate != nil && [self.delegate respondsToSelector:@selector(holdAction:)]) |
61 if (self.delegate != nil && [self.delegate respondsToSelector:@selector(holdAction:)]) |
56 [self.delegate holdAction:self.textLabel.text]; |
62 [self.delegate holdAction:self.textLabel.text]; |