我正在用卡钱包创建一个库,但是当我按下 Controller 中的按钮不起作用时,我不知道我的实例是否坏,请需要帮助。
项目的存储库位于 github 中,这是链接: https://github.com/RAES9/WalletOfCards
名称类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
最佳答案
我为我的 Controller 创建了新的变量,并在其中添加了新的 subview
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
关于ios - 当位于 subview 时,我无法将按钮的 touchUpInside 调用到 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60104723/