当我选择一个单元格时,我想将单元格中的文本添加到同一位置的底层 UIView。
所以 UIView 中的文本应该和单元格中的文本在同一位置。我不知道如何将单元格原点映射到 UIView 原点。
任何人有任何提示?
您可以使用 UIView 的convertPoint:fromView:
and convertPoint:toView
(以及相应的convertRect:...
)在坐标系之间进行转换。
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.
如果我做对了,您首先要找到所选单元格的位置。为此,您可以使用以下rectForRowAtIndexPath:
方法UITableView
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CGRect rect = [tableView rectForRowAtIndexPath:indexPath];
}