0
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)
}
不知道爲什麼我得到這個錯誤。當按下按鈕時,應用程序崩潰。漂亮的代碼和可能丟失的東西在這裏......無法識別的選擇器發送到實例swift。 'NSInvalidArgumentException'錯誤
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代碼。
什麼是無法識別的選擇器的名稱? – almas
這是說PopPop按鈕的動作。 – JammyBugger
你的代碼中有一個叫做'PopPop'的方法嗎?您是否將'PopPop'重命名爲'closePopPop',並且沒有重新連接筆尖的插座? – almas