abdullahselek / ASCollectionView

Lightweight custom collection view inspired by Airbnb.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CollectionView layout should be extended ASCollectionViewLauout

sensuikan1973 opened this issue · comments

I tried the simple code like your demo, but I couldn't....
I don't understand why this error message shows.
I would like to tell me the reason.

When the indexPath.row == 3, sumilator crash and shows the error "CollectionView layout should be extended ASCollectionViewLauout".

class VC_Question: UIViewController, ASCollectionViewDataSource, ASCollectionViewDelegate {
    
    @IBOutlet weak var collectionView: ASCollectionView!
    var numberOfItems: Int = 10
    let collectionElementKindHeader = "Header";
    let collectionElementKindMoreLoader = "MoreLoader";
    
    override func viewDidLoad() {
        super.viewDidLoad()
        collectionView.register(UINib(nibName: collectionElementKindHeader, bundle: nil), forSupplementaryViewOfKind: collectionElementKindHeader, withReuseIdentifier: "header")
        collectionView.delegate = self
        collectionView.asDataSource = self
    }
    
    // MARK: ASCollectionViewDataSource
    func numberOfItemsInASCollectionView(_ asCollectionView: ASCollectionView) -> Int {
        return numberOfItems
    }
    
    func collectionView(_ asCollectionView: ASCollectionView, cellForItemAtIndexPath indexPath: IndexPath) -> UICollectionViewCell {
        let questionCell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! QuestionCell
        return questionCell
    }
    
    func collectionView(_ asCollectionView: ASCollectionView, parallaxCellForItemAtIndexPath indexPath: IndexPath) -> ASCollectionViewParallaxCell {
        let parallaxCell = collectionView.dequeueReusableCell(withReuseIdentifier: "parallaxCell", for: indexPath) as! ParallaxCell
        return parallaxCell
    }
    
    func collectionView(_ asCollectionView: ASCollectionView, headerAtIndexPath indexPath: IndexPath) -> UICollectionReusableView {
        let header = collectionView.dequeueReusableSupplementaryView(ofKind: ASCollectionViewElement.Header, withReuseIdentifier: "header", for: indexPath)
        return header
    }
    
    func loadMoreInASCollectionView(_ asCollectionView: ASCollectionView) {
        if numberOfItems > 30 {
            collectionView.enableLoadMore = false
            return
        }
        numberOfItems += 10
        collectionView.loadingMore = false
        collectionView.reloadData()
    }
    
}
import Foundation
import ASCollectionView
class QuestionCell: UICollectionViewCell {
    
}
import Foundation
import UIKit
import ASCollectionView
class ParallaxCell: ASCollectionViewParallaxCell {
    
}