'I can't present a segue to another VC from a UIView class
I have a UIView class which i set it up as a pop-up that user needs to write a price and press a button to pay that amount, The problem is I can't set up the button to make a segue to another VC which I will use to make the payment.
I am getting errors which doesn't confront to the UIView Class because there is no method matching...
Code of popUpView
class:
class popUpView: UIView, UITextFieldDelegate {
@IBOutlet weak var popUpViewInterface: UIView!
@IBOutlet weak var infoLabelPopUp: UILabel!
@IBOutlet weak var closeButtonPopUp: UIButton!
@IBOutlet weak var priceButtonPopUp: UIButton!
@IBOutlet weak var priceInfoPopUp: UILabel!
@IBOutlet weak var priceTextFieldPopUp: UITextField!
@IBOutlet weak var payNowPopUp: UIButton!
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
xibSetup(frame:CGRect(x: 0, y: 0, width: frame.width, height: frame.height))
}
func xibSetup(frame: CGRect){
let view = loadXib()
view.frame = frame
addSubview(view)
popUpViewInterface.layer.cornerRadius = 10
}
func loadXib() -> UIView {
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: "popUpView", bundle: bundle)
let view = nib.instantiate(withOwner: self, options: nil).first as? UIView
return view!
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
priceTextFieldPopUp.resignFirstResponder()
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
priceTextFieldPopUp.resignFirstResponder()
return true
}
func cornerRadiusSetUp() {
let radius = 5
priceTextFieldPopUp.layer.cornerRadius = CGFloat(radius)
}
@IBAction func payNowToWebView(_ sender: Any) { // This is where the segue needs to happen but I am getting different kind of errors.
let myColor = UIColor.red
priceTextFieldPopUp.layer.borderColor = myColor.cgColor
priceTextFieldPopUp.layer.borderWidth = 1.0
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|