問(wèn)題描述
我有下面的結(jié)構(gòu)...
我將兩個(gè)集合視圖包裝到 tableview 中
I wrap two of collection views into tableview
一個(gè)在tableview header(Collection1),另一個(gè)在tableview第一行(Collection2).
One is in tableview header(Collection1), another is in tableview 1st row(Collection2).
所有功能都很好(兩個(gè)集合視圖).
All the functions are good (Both collection view).
只是……
當(dāng)我在 Collection2 中向上滾動(dòng)時(shí),Collection1 不會(huì)一起向上滾動(dòng),因?yàn)槲抑粷L動(dòng) collectionViews 而不是 tableview.
When I scroll up in Collection2, Collection1 will Not scroll up together, because I'm only scrolling the collectionViews not the tableview.
只有當(dāng)我在 Collection1 中滾動(dòng)時(shí)它才會(huì)一起滾動(dòng).
It only scroll together when I scroll in Collection1.
是否可以讓標(biāo)題視圖像應(yīng)用商店的索引輪播標(biāo)題一樣隨用戶(hù)滾動(dòng)?
Is it possible to make the header view scroll with user just like app store's index carousel header?
或者我只是去錯(cuò)了地方,我應(yīng)該用其他方式接近.
Or I just went to the wrong place, I should use other ways to approach.
推薦答案
解決方案
當(dāng)你將 CollectionView1 保留為 TableViewHeader 時(shí),CollectionView1 到達(dá)頂部后將始終位于 TableView 的頂部.如果您希望 Collection1 和 Collection2 一起向上滾動(dòng),則需要將 CollectionView1 保留在單元格中,而不是標(biāo)題中.
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 的內(nèi)容高度小于或等于 TableViewCell 的高度.正如我在 App Store 上檢查的那樣,他們總是使 SubCollectionView 內(nèi)容高度等于 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).
更多細(xì)節(jié),你可以看看我的示例項(xiàng)目
For more detail, you can take a look at my sample project
https://github.com/trungducc/stackoverflow/tree/app-商店標(biāo)頭
這篇關(guān)于UITableView 可以在里面滾動(dòng) UICollectionView 嗎?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!