【问题标题】:Make UITableViewCell into a UIView将 UITableViewCell 变成 UIView
【发布时间】:2011-06-17 02:40:03
【问题描述】:

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

UIView *cell = tableView.indexPathForSelectedRow;

UITableViewCell *cell = (UITableViewCell *)indexPath;

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

提前致谢。

【问题讨论】:

    标签: iphone uiview uitableview didselectrowatindexpath


    【解决方案1】:

    为此,请使用:

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    

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

    即。 cell.framecell.bound

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2012-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-13
        • 2017-05-16
        • 1970-01-01
        相关资源
        最近更新 更多