开发者

How can i Get container UITableView in a cell of the TableView

is any way to access th开发者_JS百科e UITableView that contains current UITableViewCell in the cell?


You can go up the view hierarchy until you find a UITableView:

    UIView *v = self;
    while (v && ![v isKindOfClass:[UITableView class]]) v = v.superview;
    // v now holds the table view, or nil if there isn't one

Although you should probably question why exactly the cell is needing to poke at the table view, and whether there is a more straightforward way to do it.


For iOS 8+:

UITableView *tableView = cell.superview.superview;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜