uitableviewcell的长按事件-创新互联
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 1.0; //seconds 设置响应时间
lpgr.delegate = self;
[mTableView addGestureRecognizer:lpgr]; //启用长按事件
[lpgr release];
-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer //长按响应函数
{
CGPoint p = [gestureRecognizer locationInView:mTableView ];
//if(gestureRecognizer.state == UIGestureRecognizerStateBegan)
//{
//NSLog(@"UIGestureRecognizerStateBegan");
//}
//else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)
//{
//NSLog(@"UIGestureRecognizerStateEnded");
//}
//else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)
//{
//NSLog(@"UIGestureRecognizerStateChanged");
//}
//else if(gestureRecognizer.state == UIGestureRecognizerStateCancelled)
//{
//NSLog(@"UIGestureRecognizerStateCancelled");
//}
//else if(gestureRecognizer.state ==UIGestureRecognizerStateFailed )
//{
//NSLog(@"UIGestureRecognizerStateFailed");
//}
NSIndexPath *indexPath = [mTableview indexPathForRowAtPoint:p];//获取响应的长按的indexpath
if (indexPath == nil)
NSLog(@"long press on table view but not on a row");
else
NSLog(@"long press on table view at row %d", indexPath.row);
}
网站名称:uitableviewcell的长按事件-创新互联
转载注明:http://cdiso.cn/article/dhpjdo.html
lpgr.minimumPressDuration = 1.0; //seconds 设置响应时间
lpgr.delegate = self;
[mTableView addGestureRecognizer:lpgr]; //启用长按事件
[lpgr release];
-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer //长按响应函数
{
CGPoint p = [gestureRecognizer locationInView:mTableView ];
//if(gestureRecognizer.state == UIGestureRecognizerStateBegan)
//{
//NSLog(@"UIGestureRecognizerStateBegan");
//}
//else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)
//{
//NSLog(@"UIGestureRecognizerStateEnded");
//}
//else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)
//{
//NSLog(@"UIGestureRecognizerStateChanged");
//}
//else if(gestureRecognizer.state == UIGestureRecognizerStateCancelled)
//{
//NSLog(@"UIGestureRecognizerStateCancelled");
//}
//else if(gestureRecognizer.state ==UIGestureRecognizerStateFailed )
//{
//NSLog(@"UIGestureRecognizerStateFailed");
//}
NSIndexPath *indexPath = [mTableview indexPathForRowAtPoint:p];//获取响应的长按的indexpath
if (indexPath == nil)
NSLog(@"long press on table view but not on a row");
else
NSLog(@"long press on table view at row %d", indexPath.row);
}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
成都创新互联公司是一家专注于成都网站设计、做网站与策划设计,银川网站建设哪家好?成都创新互联公司做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:银川等地区。银川做网站价格咨询:18982081108网站名称:uitableviewcell的长按事件-创新互联
转载注明:http://cdiso.cn/article/dhpjdo.html