我使用LBTAComponents
莢 這是一個豆莢,使得更容易UICollectionView
工作而無需任何註冊,並提供一個超級簡單的錨固系統......而在第一個項目我有前兩天,我決定使用這個框架 但我現在在uicollectionviewCells
一個我需要另一個collectionview
,我可以用物品填充,然後我需要它是滾動的問題水平把UICollectionViewCell到UICollectionView
import LBTAComponents
import UIKit
class ProductCell: DatasourceCell {
let cellId = "cellid"
let collectionView : UICollectionView = {
let layout = UICollectionViewFlowLayout()
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.backgroundColor = .black
return cv
}()
override func setupViews() {
super.setupViews()
ProductCell.addSubview(collectionView)
collectionView.frame = frame
collectionView.register(UICollectionView.self, forCellWithReuseIdentifier: cellId)
collectionView.dataSource = self
}
}
extension ProductCell : UICollectionViewDataSource{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 5
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath)
cell.backgroundColor = .white
return cell
}
}
datasourceCell
等於UICollectionViewCell
在這個豆莢裏。
,現在我得到這個錯誤:
instance member 'addsubview' cannot be used on type uiview did you use the value of this type instead?
你能幫幫我嗎?
我試圖用self.addSubview(collectionView)
,但我得到了另一個錯誤enter image description here
?使用UICollectionView可以輕鬆實現。第三方可能會增加更多的複雜性。 – PGDev
你知道這對我來說是一個挑戰,但我想我會開始傳統的方式... –
傳統方式是什麼? – PGDev