|
1 /* |
|
2 * Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 * Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 * |
|
18 * File created on 03/07/2010. |
|
19 */ |
|
20 |
|
21 //http://devblog.wm-innovations.com/2010/03/30/custom-swipe-uitableviewcell/ |
|
22 |
|
23 |
|
24 #import "HoldTableViewCell.h" |
|
25 #import "CGPointUtils.h" |
|
26 |
|
27 @implementation HoldTableViewCell |
|
28 @synthesize delegate; |
|
29 |
|
30 #define SWIPE_DRAG_HORIZ_MIN 10 |
|
31 #define SWIPE_DRAG_VERT_MAX 40 |
|
32 |
|
33 -(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { |
|
34 if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { |
|
35 delegate = nil; |
|
36 } |
|
37 return self; |
|
38 } |
|
39 |
|
40 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
|
41 [self performSelector:@selector(holdAction) withObject:nil afterDelay:0.4]; |
|
42 |
|
43 [super touchesBegan:touches withEvent:event]; |
|
44 } |
|
45 |
|
46 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
|
47 [NSObject cancelPreviousPerformRequestsWithTarget:self |
|
48 selector:@selector(holdAction) |
|
49 object:nil]; |
|
50 |
|
51 [super touchesEnded:touches withEvent:event]; |
|
52 } |
|
53 |
|
54 -(void) holdAction { |
|
55 if (self.delegate != nil && [self.delegate respondsToSelector:@selector(holdAction:)]) |
|
56 [self.delegate holdAction:self.textLabel.text]; |
|
57 } |
|
58 |
|
59 -(void) dealloc { |
|
60 self.delegate = nil; |
|
61 [super dealloc]; |
|
62 } |
|
63 |
|
64 @end |