UITableViewCell嵌套UITableView的正确姿势
来源:互联网 发布:简易个人博客php源码 编辑:程序博客网 时间:2024/05/16 10:12
内嵌UiTableView的高度计算起来太麻烦了,如何解决,就是把二级TableVIew里面的model item做到一级,然后对不同的item类型做不同的Cell,这样就Ok了。给一个得到Cell的源码供大家参考
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { // Get a new or recycled cell let item = tableItems[indexPath.row] if type(of: item) == Review.self{ let cell = tableView.dequeueReusableCell(withIdentifier: "ReviewCell", for: indexPath) as! ReviewCell cell.review = item as! Review cell.updateViews() return cell }else{ let cell = tableView.dequeueReusableCell(withIdentifier: "ReplyCell", for: indexPath) as! ReplyCell cell.reply = item as! Reply cell.updateViews() return cell } }
参考:https://segmentfault.com/q/1010000005595959
阅读全文
0 0
- UITableViewCell嵌套UITableView的正确姿势
- 搜索的正确姿势
- 读开源库的正确姿势
- 跑步的正确姿势
- 跑步的正确姿势
- 正确的关机姿势
- 正确的科研姿势
- UITableView与UITableViewCell的使用
- UITableView与UITableViewCell的透明度
- UITableView和UITableViewCell的关系
- 电脑前的正确姿势
- 二分查找的正确姿势
- 集成sdk的正确姿势
- Fragment使用的正确姿势
- git 的正确使用姿势
- PullToRefreshListView addHeadView的正确姿势
- 使用libcurl的正确姿势
- datasheet 使用的正确姿势
- 陶陶摘苹果(升级版)
- 还原
- (转)FOF、MOM投资模式与金融科技应用展望
- CI 框架利用hooks 做登录/权限验证
- mysql在window下的安装
- UITableViewCell嵌套UITableView的正确姿势
- android组件之DrawerLayout(抽屉导航)-- 侧滑菜单效果
- css3的box-shadow图层阴影效果
- [2017/05/18]操作系统调度算法--最短剩余时间优先算法的模拟实现
- 使用windows访问和管理linux服务器--putty
- 半同步/半异步模式和领导者/追随者模式
- NOIP 2008 普及组 复赛 drawing 立体图
- es6开发:ES6学习笔记
- C++作业5