0

当我选择一个单元格时,我想将单元格中的文本添加到同一位置的底层 UIView。

所以 UIView 中的文本应该和单元格中的文本在同一位置。我不知道如何将单元格原点映射到 UIView 原点。

任何人有任何提示?

4

3 回答 3

1

您可以使用 UIView 的convertPoint:fromView:and convertPoint:toView(以及相应的convertRect:...)在坐标系之间进行转换。

于 2010-02-28T15:50:08.303 回答
0

I found the answer you can do the following

`

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

`

Set the view frame as rectInSuperview.

于 2011-07-18T14:09:59.217 回答
0

如果我做对了,您首先要找到所选单元格的位置。为此,您可以使用以下rectForRowAtIndexPath:方法UITableView

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    CGRect rect = [tableView rectForRowAtIndexPath:indexPath];
}
于 2010-02-28T15:55:25.133 回答