Search code examples
swiftcosmicmind

How Do I Dismiss a CardView


There is likely an obvious answer but not sure why I'm missing it.

    btn2.addTarget(self, action: #selector(ViewController.dismiss(_:)), forControlEvents: UIControlEvents.TouchUpInside)

    func dismiss(sender: FlatButton){
        self.dismissViewControllerAnimated(true, completion: nil)
}

I removed all unnecessary code for simplicity sake. The btn2 code is all within a separate func.


Solution

  • Found a solution.

    Use

    self.cardView.removeFromSuperview()  
    

    That can be accessed in a separate func.