【发布时间】:2015-05-30 18:23:59
【问题描述】:
我在网上看到了许多关于将 UICollectionViews 嵌入动态表格视图单元格和子类化集合视图以设置委托的在线教程,但我想知道该过程对于静态表格视图单元格是否有任何不同。
我尝试按照示例 here 进行操作,但我无法完全按照它进行操作,因为它似乎过于复杂,几乎没有解释。有人介意概述一下我需要完成的基本步骤以使我的收藏视图正常工作吗?
到目前为止,这是我的代码:
class FeaturedController: UITableViewController, UIScrollViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
popularCollectionView.dataSource = self
popularCollectionView.delegate = self
}
//MARK: Popular Events Collection View
@IBOutlet weak var popularCollectionView: UICollectionView!
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = popularCollectionView.dequeueReusableCellWithReuseIdentifier("popular", forIndexPath: indexPath) as! UICollectionViewCell
return cell
}
非常感谢!
【问题讨论】:
标签: ios uitableview swift uicollectionview