Add OTP View in custom input view for UITextfield - ios

My UItextField has a custom number keyboard input view, how to integrate the auto capture OTP feature in the custom keyboard.
My code
let inputView = MyCustomInputView()
textField.inputView = inputView
inputView.delegate = self

Read the docs it states cleary you cannot do that.
Warning
If you use a custom input view for a security code input text field,
iOS cannot display the necessary AutoFill UI.

If I understood your question correctly, you should set the .textContentType property of your textfield to .oneTimeCode
textField.textContentType = .oneTimeCode
From Apple:
The expectation that a text input area specifies a one-time code for
delivery over SMS.

Related

Custom Keyboard on iOS

I need to create a custom keyboard for my app, but no sure the best way to do it without the user needing to add a keyboard in the settings. If I create a keyboard extension is it possible to set a UITextField's Keyboard Type to that custom keyboard? Or will I have to use a UIView to accomplish this?
For a custom keyboard that is specific to a single app, create a view and assign the view to UITextField.inputView:
textField.inputView = YourCustomKeyboard()
In my search I didn't find a way to tack on additional keys but there are examples of custom keyboards using inputView that are easy to adapt.
A custom decimal keyboard example
My hexadecimal keyboard version
You can add accessoryView to text view for you want to give a few extra buttons.
If you still looking for some more then please go through the below link.
https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=keyboard

User secure text keyboard without secure text enable in text field?

I want to use below image keyboard with ".?123".
When we enable secure text for a password in UITextField it displays below the keyboard.
I want to display this keyboard without secure text in other UITextField.
Let me know if anybody has a solution for this.
You can set keyboard type from attribute inspector from story board..
You can also set it programatically like this
txtField.keyboardType = UIKeyboardType.default
So you can check it like this...
if txtField.isSecureTextEntry {
txtField.keyboardType = UIKeyboardType.default // whatever you want to set.
}
By default iOS Doesn't change the keyboard either the entry is secure or not.
Keyboard style is an independent property from data entry security.
You can change the keyboard type to .default, .numberPad, .phonePad, .email, .url by setting it to the property keyboardType of UITextField object.
yourTextField.keyboardType = .asciiCapable
You can also achieve above task from your Storyboard or Xib to know how to use in Xib and Storyboard please refer to Mahendra GP's answer above.

Check if user has auto-correction enabled iOS

I have a UITextView which has other views right at the bottom of it. I need to move the content of the text view up when auto-correction is enabled, so that the other views don't cover the little auto-correction window. However, if the pop-up windows never appears, it looks pointless to move the view up. Any suggestions?
You can check it by :
Swift 2.2
if textField.autocorrectionType == .Yes {
//do some stuff when auto correction is enabled
}
UITextField has a property autocorrectionType that is related with UITextAutoCorrectionType enum. AppleDocumentation about it:
//
// UITextAutocorrectionType
//
// Controls keyboard autocorrection behavior for a text widget.
// Note: Some input methods do not support inline autocorrection, and
// instead use a conversion and/or candidate selection methodology. In such
// cases, these values are ignored by the keyboard/input method implementation.
//

iOS: How do I change keyboard type?

iOS: I have a problem changing my keyboard type.
It is quite simple to do if the input is into a UITextfield, e.g.
[textField setKeyboardType:UIKeyboardTypeNumberPad];
but I am NOT using a UITextfield. (All the examples I’ve seen are for UITextFields.)
I click on an array of numbers and, getting the row, column indices, wait for input provided by the UIKeyInput protocol, i.e. using its canBecomeFirstResponder, hasText, and insertText methods.
It works fine, but I get the default keyboard.
The keyboardType property is in UITextInputTraits, but I don’t know to get to it.
Assuming that you're using the keyboard for your own custom view rather than an existing view, implement the UITextInputTraits protocol in your view. Then your view will have a keyboardType property just like UITextField and others.

How to connect UITextView to a home made keyboard?

I have a UITextView field meant to receive input from a keyboard.
But the standard keyboard not being adequate for my app, I built another one with the buttons and characters I need.
I would normally make use of the UITextViewDelegate protocol and things would work.
But in this situation, how do I connect the UITextView field and my new keyboard?
Is there a "best way to do it"?
Thanks in advance for any relevant information.
Set your custom view as inputView of the UITextView.
// Edit: additional information:
Your custom keyboard will be a collection of buttons. You can add the same selector as target for all those buttons. Than your callback could be:
- (void) buttonTouched: (UIButton*) button
{
myTextView.text = [myTextView.text stringByAppendingString: button.text];
}

Resources