Git Product home page Git Product logo

Comments (4)

Root-vb avatar Root-vb commented on August 20, 2024

@Gerald-Alpha Can you please share the code of view controller.

Steps :

  1. ADD pod 'OTPFieldView' in Podfile
  2. Run pod update
  3. Drag and drop an empty view and from IDENTITY INSPECTOR in Left pane and change its class from UIView to OTPFieldView.
  4. Follow Readme and customize as per your requirements.

from otpfieldview.

geraldoluoch avatar geraldoluoch commented on August 20, 2024

Here is my view controller

`import UIKit
import OTPFieldView

class OTPViewController: UIViewController, UITextFieldDelegate {

@IBOutlet weak var otpTextFieldView: OTPFieldView!

func setupOtpView() {
           self.otpTextFieldView.fieldsCount = 5
           self.otpTextFieldView.fieldBorderWidth = 2
           self.otpTextFieldView.defaultBorderColor = UIColor.black
           self.otpTextFieldView.filledBorderColor = UIColor.green
           self.otpTextFieldView.cursorColor = UIColor.red
           self.otpTextFieldView.displayType = .underlinedBottom
           self.otpTextFieldView.fieldSize = 40
           self.otpTextFieldView.separatorSpace = 8
           self.otpTextFieldView.shouldAllowIntermediateEditing = false
           self.otpTextFieldView.otpInputType = .numeric
           self.otpTextFieldView.delegate = self
          self.otpTextFieldView.initializeUI()

       }

@IBAction func completeOTPBtn(_ sender: Any) {
    let storyBoard: UIStoryboard = UIStoryboard(name: "Login", bundle: nil)
    let PermissionNotifyViewController = storyBoard.instantiateViewController(withIdentifier: "PermissionNotify") as! PermissionNotifyViewController
    self.present(PermissionNotifyViewController, animated: true, completion: nil)

}
override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

}

}

enum DisplayType: Int {
    case circular
    case roundedCorner
    case square
    case diamond
    case underlinedBottom

}

extension OTPViewController: OTPFieldViewDelegate {
    func hasEnteredAllOTP(hasEnteredAll hasEntered: Bool) -> Bool {
        print("Has entered all OTP? \(hasEntered)")
        return false
    }

    func shouldBecomeFirstResponderForOTP(otpTextFieldIndex index: Int) -> Bool {
        return true
    }

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

/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destination.
   // Pass the selected object to the new view controller.

}
*/`

from otpfieldview.

geraldoluoch avatar geraldoluoch commented on August 20, 2024

Done all steps correctly as advised, but still not working

from otpfieldview.

Root-vb avatar Root-vb commented on August 20, 2024
override func viewDidLoad() {
    super.viewDidLoad()

    // You forgot to add this.
    self.setupOtpView()
}

from otpfieldview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.