这是应用商店中Ganna应用的图片:
当用户单击顶部的搜索栏时,会弹出此 View 。我相信他们使用 UISearchController
(将 ScrollView
传递给 UISearchController
的构造函数)和那个 ScrollView
来实现它> 还包含用于最近搜索的水平滚动 CollectionView
(在顶部),但我很困惑他们如何将趋势列表放在它下面。这是趋势部分的 TableView
吗?
还有人知道如何构建这种类型的 UI 吗?
编辑:
单个 TableView 是否可以将标题作为最近的搜索 Collection View ,其余部分作为表格 View 单元格?
最佳答案
当您滚动整个 View 时,“最近的搜索”是否会向上滚动? (我在我的应用商店中找不到这个应用'
如果是这样,您可以将表格单元格自定义为两种不同的类型,并在第一部分中使用“collectionview”。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell : UITableViewCell!
if indexPath.section == 0 {
cell = tableView.dequeueReusableCell(withIdentifier: "id of cell contain colletoinview for recent search", for: indexPath)
} else {
cell = tableView.dequeueReusableCell(withIdentifier: "id of cell for trending", for: indexPath)
}
return cell!
}
如果没有,您可以在 uiviewcontroller 中同时使用“ Collection View ”和“表格 View ”。
class SampleController : UIViewController {
@IBOutlet var trendingTableView : UITableView!
@IBOutlet var recentSearchCollectionView : UICollectionView!
}
extension SampleController : UITableViewDelegate, UITableViewDataSource {
// handle your tableview, Implement protocol
}
extension SampleController : UICollectionViewDelegate, UICollectionViewDataSource {
// handle your collectionview, Implement protocol
}
你甚至可以自定义scrollview。(真的不推荐)
关于ios - 如何创建一个顶部是 Collection View 而底部是列表的可 ScrollView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45047875/