首页 > 解决方案 > instagram 故事布局集合视图 swift - 以编程方式

问题描述

我想知道如何更好地设置 UI:目标是完成一个类似 instagram 提要的界面,例如:Instagram的

根据我的检查,它似乎是collectionView带有标题的,在该标题中放置了所有故事(圆形元素)的水平集合视图。

如果我在collectionView内部设置 a,viewController's view我可以使用控制器在视图(collectionView)和模型(firestore 后端)之间使用 MVC 进行调解。

如果我collectionView在以这种方式设置的标题内设置水平:

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
    let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerIdentifier, for: indexPath)
    
    return headerView
}

我如何在 和 之间进行viewcontroller通信collectionview's header?使用代表?我不知道哪个是最好的解决方案,因为使用标题对我来说似乎不是最好的选择。

如果你有更好的选择,我会很乐意倾听。

标签: swiftuicollectionviewheaderinstagramcollectionview

解决方案


推荐阅读