【发布时间】:2017-10-10 15:25:58
【问题描述】:
我正在尝试使用已完成的类别/故事栏实现 Letgo 或类似 Instagram 的样式提要。但是当我滚动浏览帖子时,它只会在单元格内滚动,而不是作为一个整体视图。因此,故事栏一直停留在那里,直到我到达集合视图的末尾,然后故事栏滚动但又向下滚动,因为单元格的行为就像没有足够的单元格一样。
这就是我已经实现的单元格。
override func viewDidLoad() {
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
self.tableView.dataSource = self
self.tableView.delegate = self
}
// MARK: - UITableViewDatasourse
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.row {
case 0:
return tableView.dequeueReusableCell(withIdentifier: "categoryCell", for: indexPath) as! CategoryTableViewCell
default:
return tableView.dequeueReusableCell(withIdentifier: "productCell", for: indexPath) as! ProductTableViewCell
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.row {
case 0:
return 110
default:
return tableView.frame.height - 110
}
}
我将类别栏的高度设置为 110,框架的其余部分用于提要。一切都在常规视图控制器中。如果有更好的方法来解决这个问题,我还可以点击栏与提要进行交互,我愿意重新编程所有内容。
结构: 视图控制器
-表格视图
—CategoriesCell(高度 110)
——CollectionView(hor)
——PostsCell(如何根据CollectionView内容使这个动态化)
——CollectionView(版本)
【问题讨论】:
-
如果你想要 Instagram 风格,为什么不使用IGListKit?
-
@Paulw11 不,我加载了两种不同的类型,一切都不是问题。问题是,当它全部加载并且帖子加载并且我想滚动帖子时,它只会在单元格内部滚动,所以如果我将单元格高度设为 200 或 2000,它不会作为一个整体滚动.就像当您滚动故事栏时仍然存在一样。当我向上滚动故事栏时,您可以看到帖子单元格的结尾。这不是一个一致的滚动,而是两个单独的滚动。
标签: ios swift uitableview uicollectionview