我有一个集合视图,其方向设置为水平,并且启用了分页。事实是,我的收集单元每页的高度有时高于电话屏幕的尺寸。我要实现的是用户可以向下滚动单元格并向右滑动到下一页。
当前,我只能将收集单元格显示整整一页,而无法根据内容高度向下滚动。这里是一些代码:
extension EventListDetailsVC: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return dataArray.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cat = dataArray[indexPath.row]
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "celldetails", for: indexPath) as? EventListDetailsCVC
cell?.imageEvent.image = UIImage(named: cat.imageEvent)
cell?.eventTitleLabel.text = cat.titleEvent
cell?.eventDescriptionLabel.text = cat.content
return cell!
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: self.collectionView.frame.size.width, height: self.collectionView.frame.size.height)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets.zero
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
}
这应该是
我试图将我的collectionView嵌入到tableView中,但是似乎不起作用,因为我在单元格中具有动态高度。
是实现这一目标的另一种方式吗?
p / s我刚刚开始学习敏捷,谢谢。
答案 0 :(得分:1)
您是否尝试过将滚动视图嵌入每个集合视图单元格中?
这将确保收藏夹视图单元格高度不会超过手机高度,而滚动视图将在您向下滚动时显示更多内容,无论是文本或图像还是您决定嵌入滚动视图本身的任何视图
答案 1 :(得分:0)
我认为您应该尝试使用scroll
过渡风格的UIPageViewController。页面之间具有本机分页。
每个页面都应具有UIScrollView。