swift - 每个 UICollectionView 单元格中的 UITableView
问题描述
我一直在寻找有关在 UICollectionView 单元格中获取 UITableView 的信息,但到目前为止,我只找到了确切的对立面:TableView 单元格中的 CollectionViews。我的方法如下:
集合视图控制器:
class CollectionViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 5
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath) as! CollectionViewCell
return cell
}
}
自定义 CollectionViewCell:
class CollectionViewCell: UICollectionViewCell {
override func awakeFromNib() {
super.awakeFromNib()
let tableView = UITableView()
self.contentView.addSubview(tableView)
}
}
目标是让信息显示在水平滚动的页面中,并且每个页面可以有很多行(因此 CollectionViews 中的 TableViews)。但是,我似乎无法弄清楚如何为每个添加到 CollectionView 单元格的 TableView 实例添加一个 TableViewController。
提前致谢。
解决方案
不确定这是否真的值得回答......但回到我们的评论讨论......
您可以像任何 UIView 或 UIViewController 一样使 UICollectionView 符合 tableview 协议。
推荐阅读
- ocr - 如何针对非语言特定文本(例如车牌)改进 Google Vision API 的 TEXT_DETECTION
- mysql - DATE_FORMAT 与字符串和数字进行比较
- axios - Nuxt.js 套接字挂断在 axios 上仅在 https 而不是 http 服务器上获取
- php - 如何仅通过正则表达式查找 .xml 链接和日期
- vb.net - 有没有办法在 vb 控制台应用程序中运行语音识别?
- javascript - 为什么 async 在 JS 中返回 Promise
- playframework - 数据库“默认”处于不一致状态
- angular - 如何从 Angular 7 中的支付网关读取重定向 POST url 到我们项目的响应?
- angular - 角度 7 导入 html
- sql - 如何删除查询中的重复项?