2017-04-14 53 views
0

我有我的`.xib'这样的自定义视图VPMOTPViewenter image description here在xib中自定义视图不工作

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)") 
    } 
} 

然后在我的“视图控制器”

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!) 

但是,这是我可以在屏幕上看到我的重发OTP按钮,但不显示OTPVIEW。

+0

您是否将其课程设置为故事板中的相应课程? –

回答

0

从屏幕截图看,您看起来没有任何限制吗?

如果不尝试添加约束并查看是否解决了问题。

+0

该死的真棒观察。谢谢。 :) – Nitesh

+0

没问题,很高兴我能帮上忙 –

相关问题