-
Notifications
You must be signed in to change notification settings - Fork 0
/
TableViewCell.m
executable file
·71 lines (52 loc) · 1.89 KB
/
TableViewCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// TableViewCell.m
// PostBar
//
// Created by chen on 6/9/11.
// Copyright 2011 http://cnblogs.com/mainPage/. All rights reserved.
//
#import "TableViewCell.h"
@implementation TableViewCell
@synthesize delegate;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
UISwipeGestureRecognizer *swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(tablecellswipeLeft)];
swipeleft.direction=UISwipeGestureRecognizerDirectionLeft;
[self addGestureRecognizer:swipeleft];
[swipeleft release];
UISwipeGestureRecognizer *swipeRight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(tablecellswipeRight)];
swipeRight.direction=UISwipeGestureRecognizerDirectionRight;
[self addGestureRecognizer:swipeRight];
[swipeRight release];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state.
}
- (void)dealloc {
[super dealloc];
}
#pragma mark -
#pragma mark myAction
- (void) handdleLeftSwipe {
if (delegate && [delegate respondsToSelector:@selector(swipeLeft)]) {
[delegate swipeLeft];
}
}
- (void) handdleRightSwipe {
if (delegate && [delegate respondsToSelector:@selector(swipeRight)]) {
[delegate swipeRight];
}
}
-(void)tablecellswipeLeft{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(tablecellswipeLeft) object:nil];
[self performSelector:@selector(handdleLeftSwipe) withObject:nil afterDelay:0.2f];
}
-(void)tablecellswipeRight{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(tablecellswipeRight) object:nil];
[self performSelector:@selector(handdleRightSwipe) withObject:nil afterDelay:0.2f];
}
@end