當您滾動整個視圖時,「最近搜索」是否向上滾動? (我不能在我的應用程序商店發現這個程序」
如果是這樣,你可以自定義的表格單元格,以兩種不同的類型,並使用‘的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同時使用「集合視圖」和「表格視圖」。
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
}
你甚至可以自定義滾動視圖。(真的不推薦)
我的想法完全一樣,你的第一選擇實際上也是。您還可以使Recent Searches'CollectionView'成爲標題單元格,其餘的底部部分通常使單元格離隊。謝謝您的幫助! – CapturedTree
很高興爲您效勞。 :) – Codus
在SnapChat中,我想知道如何創建在您點擊snapchat中的搜索欄時顯示的視圖?我正在考慮有一個大的'TableView'。然後在主'TableView'中創建一個名爲'Top Stories'的部分並在其中放置一個'CollectionView'。然後在下一部分有另一個部分,例如('我的周圍','旅行'等)。然後在該部分有一個水平的'CollectionView',其中的每個單元格中的單元格都與類別和垂直的'CollectionView'一樣多。這是你想要的方式嗎? – CapturedTree