問題描述
我有下面的結構...
我將兩個集合視圖包裝到 tableview 中
I wrap two of collection views into tableview
一個在tableview header(Collection1),另一個在tableview第一行(Collection2).
One is in tableview header(Collection1), another is in tableview 1st row(Collection2).
所有功能都很好(兩個集合視圖).
All the functions are good (Both collection view).
只是……
當我在 Collection2 中向上滾動時,Collection1 不會一起向上滾動,因為我只滾動 collectionViews 而不是 tableview.
When I scroll up in Collection2, Collection1 will Not scroll up together, because I'm only scrolling the collectionViews not the tableview.
只有當我在 Collection1 中滾動時它才會一起滾動.
It only scroll together when I scroll in Collection1.
是否可以讓標題視圖像應用商店的索引輪播標題一樣隨用戶滾動?
Is it possible to make the header view scroll with user just like app store's index carousel header?
或者我只是去錯了地方,我應該用其他方式接近.
Or I just went to the wrong place, I should use other ways to approach.
推薦答案
解決方案
當你將 CollectionView1 保留為 TableViewHeader 時,CollectionView1 到達頂部后將始終位于 TableView 的頂部.如果您希望 Collection1 和 Collection2 一起向上滾動,則需要將 CollectionView1 保留在單元格中,而不是標題中.
Solution
When you keep CollectionView1 as a TableViewHeader, CollectionView1 will always on the top of TableView after it reaches top. If you want Collection1 and Collection2 scroll up together, you need to keep CollectionView1 in a cell, not a header.
確保 CollectionView2 的內容高度小于或等于 TableViewCell 的高度.正如我在 App Store 上檢查的那樣,他們總是使 SubCollectionView 內容高度等于 TableViewCell 的高度(如果他們使用 TableView).
Make sure CollectionView2 content height smaller or equal to TableViewCell's height. As I checked on App Store, they always make SubCollectionView content height equal to TableViewCell's height (If they use TableView).
更多細節,你可以看看我的示例項目
For more detail, you can take a look at my sample project
https://github.com/trungducc/stackoverflow/tree/app-商店標頭
這篇關于UITableView 可以在里面滾動 UICollectionView 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!