簡體   English   中英

在tableView中滾動時,如何隱藏collectionView(知道此ViewCOntroller是tableview的一半,collectionview的一半)

[英]How can I hide a collectionView when scrolling in my tableView (knowing that this ViewCOntroller is half tableview and half collectionview)

所以我有一個UIViewController ,它具有一個水平滾動的collectionView (例如newsFeed頁面頂部的facebook故事),在它的下面是帶有單元格的tableView 向下滾動tableView時如何隱藏此集合視圖? 我希望它完全像facebook。

所以我把故事放在最上面,作為collectionViews

您必須設置collectionView高度約束,並且在開始拖動表格視圖時:

heightConstraint.constant = 0

您可以了解從表視圖委托開始拖動的知識。 為此,您應該從UITableViewDelegate繼承viewController並設置一個函數:

class ViewController: UIViewController, UITableViewDelegate {
    override func viewDidLoad() {
    super.viewDidLoad()
    self.tableView.delegate = self
    }

    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
    print("begin dragging")
    heightConstraint.constant = 0
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM