开发者

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

开发者 https://www.devze.com 2023-02-27 09:46 出处:网络
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:

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

精彩评论

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