gpt4 book ai didi

ios - xib 中的自定义 View 不起作用

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

我有VPMOTPView我的“.xib”中的自定义 View 如下所示。 enter image description here

class VerifyOTP: UIView {

@IBOutlet weak var otpView: VPMOTPView!

var emailID = ""
var userID = ""

@IBAction func resendOTPAction(_ sender: UIButton) {
print("asdds")
}
override func awakeFromNib() {
super.awakeFromNib()

otpView.otpFieldsCount = 4
otpView.otpFieldDefaultBorderColor = UIColor.blue
otpView.otpFieldEnteredBorderColor = UIColor.red
otpView.otpFieldBorderWidth = 2
otpView.delegate = self

// Create the UI
otpView.initalizeUI()

}

}

extension VerifyOTP: VPMOTPViewDelegate {
func hasEnteredAllOTP(hasEntered: Bool) {
print("Has entered all OTP? \(hasEntered)")
}

func enteredOTP(otpString: String) {
print("OTPString: \(otpString)")
}
}

然后在我的“ViewController”中

var verifyOTPView: VerifyOTP?
self.verifyOTPView = VerifyOTP.fromNib()
self.verifyOTPView?.frame = CGRect(x: 20, y: 0, width: screenSize.width - 40, height: screenSize.height / 3)
self.view.addSubview(self.verifyOTPView!)

但是这样我可以在屏幕上看到我的 RESEND OTP 按钮,但 OTPVIEW 未显示。

最佳答案

从屏幕截图来看,您似乎没有为 View 设置任何约束?

如果没有,请尝试添加约束并查看是否可以解决问题。

关于ios - xib 中的自定义 View 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43413988/

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