ios - 当位于 subview 时,我无法将按钮的 touchUpInside 调用到 ViewController

标签 ios swift iphone uiviewcontroller subview

我正在用卡钱包创建一个库,但是当我按下 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/

相关文章:

objective-c - 在 iOS 中,NSURL 或 NSXML 是否跨越新线程?

ios - 如何使 iPhone 应用程序无法关闭?

ios - Razorpay 签名和订单 ID 未进入 onPaymentSuccess 的成功方法

swift - 使用 addChild 进行不需要的重复

ios - 处理向同一方向滚动的嵌套 UIScrollViews 的触摸

iphone - GameKit 多线程发送可能吗?

iphone - iStat for iPhone如何获取WiFi MAC和任务列表

ios - Xcode:针对特定语言导出到 XLIFF,而不是 "base"

javascript - 如何在 React-Native 上分析网络?

ios - 如何编译 `.framework`文件?