gpt4 book ai didi

swift - 无法识别的选择器发送到实例 swift。 'NSInvalidArgumentException' 错误

转载 作者:行者123 更新时间:2023-11-30 12:44:23 25 4
gpt4 key购买 nike

class PopPop: UIViewController {
var quickVouch = UIView()

@IBAction func closePopPop (sender: UIButton) {
self.view.removeFromSuperview()
}

override func viewDidLoad() {
super.viewDidLoad()

self.view.backgroundColor = UIColor.black.withAlphaComponent(0.2)

quickVouch.frame = CGRect.init(x: 0, y: 0, width: 260, height: 300)
quickVouch.backgroundColor = UIColor.black
quickVouch.center = self.view.center
quickVouch.layer.cornerRadius = 0
quickVouch.layer.shadowOpacity = 0.0
quickVouch.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
self.view.addSubview(quickVouch)

let btn: UIButton = UIButton(frame: CGRect(x: 100, y: 265, width: 60, height: 30))
btn.backgroundColor = UIColor.black
btn.setTitle("Close", for: .normal)
btn.addTarget(self, action: Selector(("buttonAction:")), for: UIControlEvents.touchUpInside)
btn.setTitleColor(UIColor.lightGray, for: .normal )
btn.titleLabel!.font = UIFont(name: "AvenirNextCondensed-Medium", size: 20)!
quickVouch.addSubview(btn)
}

不知道为什么会出现此错误。当按下按钮时,应用程序崩溃。代码非常新,可能在这里遗漏了一些东西......

func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {

let PopOverViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PopPopID") as! PopPop
self.addChildViewController(PopOverViewController)
PopOverViewController.view.frame = CGRect(x: 0, y: -70, width: 1000, height: 1000)
self.view.addSubview(PopOverViewController.view)
PopOverViewController.didMove(toParentViewController: self)


}

这是主 ViewController 中的代码。

最佳答案

我更改了这行代码,现在一切都按计划进行!

btn.addTarget(self, action: #selector(PopPop.buttonAction(_:)), for: UIControlEvents.touchUpInside)

关于swift - 无法识别的选择器发送到实例 swift。 'NSInvalidArgumentException' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41817329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com