ios - 集合视图内的表视图
问题描述
我有一个集合视图,每个集合视图单元格都有一个表格视图,每个集合视图单元格都有不同的数据。集合视图是使用情节提要完成的并且工作正常,但我似乎无法让 UITableView 在其中工作。集合视图代码如下,任何帮助表示赞赏。理想情况下,一种允许我使用故事板自定义 tableview 单元格的技术,我使用的是 Swift 4。
extension StoryboardViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt
indexPath: IndexPath) {
print("Selected Cell #\(indexPath.row)")
}
}
extension StoryboardViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 6
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: "CollectionViewCell"), for: indexPath) as! StoryboardCollectionViewCell
cell.label.text = "Cell #\(indexPath.row)"
return cell
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
print("Current centered index: \(String(describing: centeredCollectionViewFlowLayout.currentCenteredPage ?? nil))")
}
func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
print("Current centered index: \(String(describing: centeredCollectionViewFlowLayout.currentCenteredPage ?? nil))")
}
}
我想在其中放置一个表格视图(列表),如下所示:
解决方案
UICollectionViewCell
正在使用的类应符合将初始化表格视图中的单元格的UITableViewDelegate
协议UITableViewDataSource
推荐阅读
- angular - 'Could not resolve module... relative to...' 编译应用程序时出错
- python - 用我自己的操作系统刷新我的旧捕获盒
- java - 似乎无法将 int 转换为字符串并运行我的程序,因此它输出 330
- python-3.x - 内存问题?如何有效地获得所需的输出?
- php - Laravel 5.8 自定义表单请求未按预期工作?
- ruby-on-rails - 如何根据创建的对象字段值测试是否发送邮件
- c# - 使用 linq 过滤器选择父母和一些孩子
- swift - kitura中可编码路线中的多个参数
- javascript - HTML 自动播放视频并从文件夹继续循环
- css - 仅使用 css 的滑块图像:一次动画 + 过渡