UILongPressGestureRecognizer

来源:互联网 发布:现代车钥匙淘宝图片 编辑:程序博客网 时间:2024/06/11 15:05


UILongPressGestureRecognizer *longPressReger = [[UILongPressGestureRecognizer alloc]

initWithTarget:self action:@selector(handleLongPress:)];

longPressReger.minimumPressDuration = 1.0;

[myTableView addGestureRecognizer:longPressReger];

[longPressReger release];

 

-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer

{

CGPoint point = [gestureRecognizer locationInView:myTableView];

 

if(gestureRecognizer.state == UIGestureRecognizerStateBegan)

{

}

else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)

{

}

else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)

{

}

NSIndexPath *indexPath = [myTableView indexPathForRowAtPoint:point];

if (indexPath == nil)

NSLog(@”not tableView”);

else

{

focusRow = [indexPath row];

focusView.hidden = NO;

}

}


原创粉丝点击