问题
is any way to access the UITableView that contains current UITableViewCell in the cell?
回答1:
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.
回答2:
For iOS 8+:
UITableView *tableView = cell.superview.superview;
来源:https://stackoverflow.com/questions/5745576/how-can-i-get-container-uitableview-in-a-cell-of-the-tableview