我试图实现Letgo或Instagram样式的饲料与我所做的类别/故事栏。但是当我滚动文章时,它只是在单元格内滚动而不是整个视图。因此,故事栏直到我到达集合视图的末尾时才停留在那里,然后故事栏滚动,但因为单元格没有足够的单元格而表现不佳。斯威夫特: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,框架的其余部分为饲料。一切都在一个常规的视图控制器中。如果有更好的方法来处理这个问题,我也可以点击栏与Feed进行交互,我愿意重新编程一切。
结构: 的ViewController
-tableView
-CategoriesCell(高度110)
--CollectionView(HOR)
-PostsCell(如何使视的CollectionView这个动态内容)
--CollectionView(ver)
如果你想Instagram的风格,为什么不使用[IGListKit](https://github.com/Instagram/IGListKit)? – Paulw11
@ Paulw11不,我得到了两种不同的类型加载和一切都不是问题。问题是,当它全部加载和帖子加载,我想滚动通过帖子,它只滚动通过单元格内,所以如果我使单元格高度200或2000它是相同的事情,它不作为一个整体滚动。就像当你滚动故事栏时一样。当我滚动故事栏时,可以看到帖子单元格的结尾。这不是一个单一的滚动,它是两个单独的滚动。 –