且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

touchesBegan 不能在 UITableView 上工作

更新时间:2021-07-09 21:46:16

如果您只想在单击任何单元格时显示 Copy 选项,那么您必须去

if you just want to show Copy option when any cell is clicked then you have to go for

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

tableView 的方法.无需使用Touch event.

method of tableView. there is no need to use Touch event.

使用此方法,您可以使用 indexPath 获取所选单元格的副本.

Using this method you can get the copy of selected cell using indexPath.

要获取所选单元格的位置,您可以使用 rectForRowAtIndexPath 方法

To get the position of selected cell you can use rectForRowAtIndexPath method

CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];

编辑 2

CGRect rectInSuperview = [tableView convertRect:rectInTableView toView:[tableView superview]];