JoniVR / VerticalCardSwiper

A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.
MIT License
1.4k stars 101 forks source link

[Question] How do I use a button on this card to launch a new ViewController> #75

Closed Proudspark closed 3 years ago

Proudspark commented 4 years ago

New Issue Checklist

Question

A method I'm using on other ViewControllers no longer works when I attempt to use the method from the CardCell class:

@IBAction func Show_Me_Pressed(_ sender: Any) {
        let storyboard = UIStoryboard(name: "main", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "GameViewController") as UIViewController
        self.present(vc, animated: true, completion: nil)
}

returns error: Value of type 'CardCell' has no member 'present'

How can I open a ViewController over the Cards ViewController using a button on the ExampleCell.xib?

Thanks, any pointers greatly appreciated.

JoniVR commented 4 years ago

CardCell subclasses from UICollectionViewCell, so just like you would with a UICollectionViewCell. I would create either a delegate or closure for callback in this case (same way you would with UICollectionViewCell)