Cell添加左右手势

 因为项目中要用到左右滑动进每个页面的下一级,用到了给cell添加手势

 代码如下

    UISwipeGestureRecognizer *recognizer;
    recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
    
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [cell.contentView addGestureRecognizer:recognizer];
    
   [recognizer release];
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
    CGPoint location = [recognizer locationInView:mytabview];
    NSIndexPath *indexPath = [mytabview indexPathForRowAtPoint:location];
    NSLog(@"左滑动了 %d",indexPath.row);



}

 

posted @ 2013-08-13 20:28  Asial  阅读(336)  评论(0编辑  收藏  举报