UITextField keyboard. How to disable force touch? - ios

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.

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 turn off character previews letter pop ups?

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.

How to disable isEnable and isUserInteraction attributes but keep cursor show in UITextField?

I have a custom framework for UITextField. For now, I want to disable two attribute as the question above but still keep the cursor show in my custom textfield. I already disable the keyboard with set the inputView = UIView(), and that successful for hide the keyboard even show the cursor inside textField.
My goal is disable both attributes like above or another for can not Select All action from my textField, but still keep the cursor available anytime.
Hope to hear the ideas from you guys. Thank a lot!

iOS -Objective C- Prevent the keyboard automatically hide when I set enable = NO on UITextField

I'm working on an App with Objective-C but I have a problem with my form.
I have several inputs view (UITextField) on it, and one with a particularly behavior.
When I select the checkbox, I prevent the user typing on the view and looks the view as disable( grayed out and without the blue bar flashing blue bar ) and keep the keyboard open.
When I set the UITextField as disable, the keyboard is automatically hidden.
Someone knows how to keep the keyboard open?
I need to something like the image attached, but without the blue bar flashing blue bar.
I did the logic to prevent the the user enter data on the input , but the keyboard is automatically hidden.
If the text field is disabled, the user cannot type into it and the dismissal of the keyboard is correct. You should not try to fight against that. (It sounds like you're trying to disable the keyboard for the wrong reasons anyway.)
In this case, it sounds like your timing is just off. When the user clicks the checkbox, your code responds. What you are doing there is just wrong. You should respond by moving the first responder to the next enabled text field yourself, and then disabling the first text field. That way, you are not disabling the text field while it is first responder; that's your whole mistake right there.

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