0

我有一个 UITableView,在 中tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath,我希望能够访问所选单元格所在的框架。这是我正在尝试的:

UIView *cell = tableView.indexPathForSelectedRow;

UITableViewCell *cell = (UITableViewCell *)indexPath;

我希望能够访问所选单元格所在的视图。

提前致谢。

4

2 回答 2

1

为此,请使用:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

比您可以像访问其他任何人一样访问单元格上的所有信息UIView

IE。cell.frame,cell.bound等。

于 2011-06-17T03:16:36.253 回答
0

不需要直接访问单元格 - 是的,您可以通过 获取单元格及其框架-cellForRowAtIndexPath:,但是您必须减去 UIScrollView(UITableView 的子类)的内容偏移量才能获得单元格在边界内的实际位置的表视图。最好的方法是 UITableView 方法-rectForRowAtIndexPath:

于 2011-06-17T04:26:40.277 回答