Search code examples
iosswiftiphoneuiviewcontrollersubview

I can't call touchUpInside of button to ViewController when is at a subview


I'm make a library from wallet of cards, but when i am pushing a button in my controller not working, i don't kwon if my instance is bad, need help please.

The repository of project is in github this is the link: https://github.com/RAES9/WalletOfCards

The name class id WalletOfCards.swift

let controller = self.delegate?.storyboard!.instantiateViewController(withIdentifier: self.destitaionController as String)
self.delegate?.addChild(controller!)
controller!.didMove(toParent: self.delegate!)

Lines: 143,144,15.

Function: tappedButton


Solution

  • I created new var for my controller and i added new subview in this

    let controller = self.dataSource.storyboard!.instantiateViewController(withIdentifier: 
    self.destitaionController as String)
    self.dataSource.addChild(controller)
    controller.didMove(toParent: self.dataSource)
    controller.view.frame = CGRect(x: 0, y: 0, width: (cardSelected?.frame.width)!, height: (cardSelected?.frame.height)!)
    controller.view.alpha = 0.0
    self.dataSource.view.addSubview(controller.view)
    controller.view.alpha = 1.0