How to turn off character previews letter pop ups? - ios

I want a fully secure text entry in one of my text fields.
I set isSecureTextEntry to true
But when a user presses a key, the pressed character will pop up for the preview and I need to disable this.
Is there any way I can do that?
I know it can be turned off by the user in settings but I need to do that in code myself.

Related

Is it possible to have OTP autofill but manually entering is not allowed?

I have a weird problem i am facing with. I know about OTP autofill with
textField.textContentType = .oneTimeCode .
But i have a different problem, i want this autofill to work but the text field should be disabled for any manual typing.
Basically , user gets message with OTP on his/her phone and OTP gets autofilled by using .oneTimeCode. But in any case if the app can't read or find OTP through this method(from SMS) , the user should NOT be allowed to manually enter the OTP.
Is there anyway to attain this scenario ?
You can set a transparent view on textField & make its userInteraction disable. & for showing keyboard automatically you can use textField.becomeFirstResponder()
You need to disable userInteraction of view that is on your TextField:
transparentView.isUserInteractionEnabled = false
And for display keyboard automatically:
Yoy can write this line in viewWillAppear method when your otpScreen appear.
textField.becomeFirstResponder()
At first glance, my suggestion will be adding clear view to block the text field touch, but this will prevent filling the OTP
Disabling user interaction will be preventing filling the OTP too.
Maybe you can use text field delegate on text change, check the new characters. When the characters are less than your OTP length then just ignore the new characters.
textField:shouldChangeCharactersInRange:replacementString:

How to place cursor at the end of text whenever the user touches on UITextField containing that text?

In my custom UITextField the user can place an e-mail by touching on "+" button or by writing it from keyboard. The problem is when the e-mail is added through "+" button and then, someone wants to add another e-mail, this time by writing it from keyboard, the cursor instead of being at the end of the text, highlights previously written mails, but it cannot be placed at the end of the text - which is what I would like. I hope what I wrote is understandable. Anyways, do you know a way of implementing this?
I've already tried setting keyboard time and selecting text range but it brought me no good

UITextField keyboard. How to disable force touch?

I faced with an interesting problem. In my app, I have some UITextFields that could contain only one character inside.
From iPhone 6s (iOS 9) Apple has introduced a cool feature related with force touch on keyboard text field:
http://cdn.osxdaily.com/wp-content/uploads/2016/05/iphone-keyboard-trackpad.mov.gif
In my case when the text field can contain only one character is completely useless and can be very misunderstanding.
I went through the UITextField documentation and I haven't found anything that could help me.
Do you have any ideas how to solve this problem? Is it possible?
Thanks!
UPDATE
Related with #dmorrow answer:
Setting the isSecureTextEntry to true disables that feature, but in my case I want to see the input text. So the isSecureTextEntry must be false
I just tested, and textField.isSecureTextEntry = true disables this feature.
I'm not sure how you are switching your input from number to •, but if you just use the native password input you'll get the result you need.
New Idea
What if you used a hidden textfield for the input, with isSecureTextEntry = true. Each of your input fields would actually just be a UIButton. On tapping the button, the hidden textfield would become first responder. On text input, you could set the label of the button and jump to the next button as you are doing now. Any time the user taps the button, it would clear the input and allow them to type again.

How to set number side as default (while keyboard is open) of name phone pad keyboard type

Right now when the keyboard launches on my application it defaults to the letter side showing an alphabetical keyboard.
Question will be listed below images
Refer to image below:
This is good. Clicking 123 will show the number side.
The Question:
However, I want to by default show the number side and still be able to switch back to the letter side later WHEN THE KEYBOARD IS OPEN. How do I do this?
Setting the keyboard programmatically to a different type is NOT the answer!
For example: User clicks in the text field, keyboard pops up and defaults to let's say the ABC side. The user can click 123 to switch. This is what I want. If the ability to switch while the keyboard is open is taken away it defeats the point of this question.
So if the Name Phone Pad keyboard defaults to the ABC side initially. I want it to default to the 123 side that way while the keyboard is still open it can switch to ABC again when the user clicks ABC.
I want to do this because I have different settings for how to search for barcodes. Either by name of the product or number based on settings the user set about how to index results. This way if they are sorting by number it suggests numbers first, BUT they can still go back to searching by alphabetical if they wanted by clicking the ABC button on the keyboard.
Here is the current setting for my keyboard.
keyboardType is property for a UITextField.
textField.keyboardType = UIKeyboardType.UIKeyboardTypeNumberPad
and
textField.keyboardType = UIKeyboardType.UIKeyboardTypeDefault
is how you can switch between the two modes programatically. Hope that helps.
To switch the Keyboardlayout programmatically you have to mutate UITextfield's keyboardType attribute.
Try
textField.keyboardType = UIKeyboardType.NumberPad;
or
textField.keyboardType = UIKeyboardType.PhonePad;

Entering/Clearing specific UITextfields?

My aim is to have text boxes - a set amount per level for people to guess a hidden word. I don't want the UITextfield to be tapped and then bring up the keyboard, I'd like to have a different button that brings up the keyboard - if that's possible.
If each box is a separate text field how could I go about entering text. When a user types on the standard apple keypad, how could each character be inputted into a certain text field. I'd preferably like the text to show in the box as soon as a key is tapped.
I'm also having trouble clearing certain letters. Say a user mis-spells something and doesn't realise until the keyboard has resigned as first responder, how could I make it so that a user can tap on maybe two boxes if the rest of the word is spelt right and the program clear it?
Is there any way of writing the program so that it inputs text only if the text field is empty? Continuing with the example above they switch two letters, they tap to clear, they then bring up the keypad and the next key then pressed fills the empty boxes. Not allowing the program to input text in a used text field that only contains a single character?
I'm using Cocos2d - I don't know if that makes a difference. I hope you understand what I mean, although I'm rather bad at explaining.
Thank you in advance for your time and any help :).
Instead of having a textbox that you don't want users to edit, why not use a label?
To show the keyboard, you need to have it linked to some UITextField (or similar). You could use an invisible UITextField, and then monitor the input and send the characters to the correspinding labels. Refer to this question.
To check if a textfield has anything in it:
[textField.text length] > 0, but I would use labels instead of textfields.
I dont really understand the other parts of your question.

Resources