如何获取容器UITableView在TableView的单元格 [英] How can i Get container UITableView in a cell of the TableView

查看:98
本文介绍了如何获取容器UITableView在TableView的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

直到找到一个UITableView:

  UIView * v = self; 
while(v&&![v isKindOfClass:[UITableView class]])v = v.superview;
// v现在保存表视图,如果没有则为nil

虽然你可能会质疑,为什么细胞需要在桌面视图上捅,以及是否有更直接的方法来做。


is any way to access the 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.

这篇关于如何获取容器UITableView在TableView的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆