Comments (4)
@Gerald-Alpha Can you please share the code of view controller.
Steps :
- ADD
pod 'OTPFieldView'
in Podfile - Run
pod update
- Drag and drop an empty view and from IDENTITY INSPECTOR in Left pane and change its class from UIView to OTPFieldView.
- Follow Readme and customize as per your requirements.
from otpfieldview.
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.
Done all steps correctly as advised, but still not working
from otpfieldview.
override func viewDidLoad() {
super.viewDidLoad()
// You forgot to add this.
self.setupOtpView()
}
from otpfieldview.
Related Issues (20)
- How to stop copy and paste in textfeilds HOT 1
- textfield clears on orientation change HOT 1
- AutoFill One Time Security Code not working? HOT 2
- Issue in installing using pods HOT 1
- code UI does not work. HOT 1
- Mark as error functionality is not there HOT 3
- Clear text field HOT 3
- Keyboard return command
- SwiftUI Implementation HOT 1
- how to get PIN after entered??????? HOT 1
- Crash when load the view
- Border Color
- copy paste OTP not working HOT 4
- How to add shadow property to these OTP text fields?
- Pod is not installing using terminal
- the predictive otp above the keyboard is not working
- cursor should show after the number instead of before the number HOT 1
- Add property to change/customize text color HOT 2
- Textcolor Change HOT 5
- Pass a string of character to populate all the fields HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from otpfieldview.