<UI>TableViewCELL长按事件

//长按事件的手势监听实现方法
- (void) myHandleTableviewCellLongPressed:(UILongPressGestureRecognizer *)gestureRecognizer {
    if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
        NSLog(@"UIGestureRecognizerStateBegan");
    }
   if (gestureRecognizer.state == UIGestureRecognizerStateChanged) {
        NSLog(@"UIGestureRecognizerStateChanged");
    }

   if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
        NSLog(@"UIGestureRecognizerStateEnded");
    }
}
- (void)viewDidLoad
{

    //------------------------------------------------------------------------------------
    //创建长按手势监听 
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
               initWithTarget:self 
               action:@selector(myHandleTableviewCellLongPressed:)];
    
    //代理
    longPress.delegate = self;
    longPress.minimumPressDuration = 1.0;
    //将长按手势添加到需要实现长按操作的视图里
    [myTableViewControl addGestureRecognizer:longPress];


    [longPress release];
    //------------------------------------------------------------------------------------

    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
posted @ 2012-12-02 16:17  白条围巾  阅读(1978)  评论(0编辑  收藏  举报