我想添加滑動手勢識別器到tableViewCell但它不起作用。添加手勢到TableViewCell
這是我創造我的手機的方式:
CellIdentifier = @"EventsSentCell";
nibObjcet = [[NSBundle mainBundle] loadNibNamed:@"EventsSentCell" owner:self options:nil];
EventsSentCell *cell = [[EventsSentCell alloc] init];
cell = (EventsSentCell *)[nibObjcet objectAtIndex:0];
,這是我的手機是如何在.m文件啓動:
-(id)init{
self = [super init];
if (self) {
leftSwipe = [[UISwipeGestureRecognizer alloc] init];
leftSwipe.direction= UISwipeGestureRecognizerDirectionLeft;
[leftSwipe addTarget:self action:@selector(swipedLeft)];
[self addGestureRecognizer:leftSwipe];
}
return self;
}
,這是我宣佈我的手勢識別在.h文件中:
@property (nonatomic,strong) IBOutlet UISwipeGestureRecognizer *leftSwipe;
但由於某種原因我的方法沒有被調用。
任何想法?
感謝
我試圖把下面的代碼:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
NSLog(@"%@",gestureRecognizer);
return YES;
}
,結果我左刷卡後讓我的是:
<UILongPressGestureRecognizer: 0xa9d99a0; state = Possible; view = <UITableViewCellContentView 0xa9d8ce0>; target= <(action=_longPressGestureRecognized:, target=<EventsSentCell 0xa9d8bb0>)>>