intuit / CardParts

A reactive, card-based UI framework built on UIKit for iOS developers.
Other
2.52k stars 225 forks source link

Clickable CollectionView [Help Wanted] #151

Closed zacgibson21 closed 5 years ago

zacgibson21 commented 5 years ago

I can not for the life of me get the click function working on a collectionView. I have tried adding the below close to both my cell class and the main view controller with no luck.

CardPartCollectionViewDelegte { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { print("Please Print!!") }

Any advice would be appreciated

ghost commented 5 years ago

Have you assigned the delegate property of the collection view in question? A structure something like:

class MainViewController:UIViewController, UICollectionViewDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        // set the delegate to self - this doesn't have to be in viewDidLoad, just wherever you are setting
        // up the collection view's properties.
        collectionView.delegate = self
    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        print("Please Print!!")
    }

    // rest of the class code including
    // other UICollectionViewDelegateMethods...

}
croossin commented 5 years ago

@zacgibson21 Have you solved this yet? Or are you still having trouble?

croossin commented 5 years ago

Closing due to inactivity. Let us know if you still are having this issue.