Code input text field - ios

Is there a native UI control for code input text field, for example like Whatsapp:

No. To achieve this, they're almost certainly tapping into the textField:shouldChangeCharactersInRange:replacementString: method for their UITextField, selectively accepting and formatting user input to match the dash-if-empty approach.
Further, I'm sure they've subclassed the field; per your comments there isn't a blue cursor - which isn't standard for a UITextField.

No there isn't. Use a UITextField, fill it with dashes, keep track of how many characters the user has entered, and replace the dashes accordingly as the user types.

There's a 4-digit code input text field called CodeInputView written in Swift.

In the past I've added a UITextField to the view and set its hidden == true. Then I show/hide the keyboard by calling becomeFirstResponder()/resignFirstResponder() on it. I listen for text did change notifications and update a visible label with the value of the hidden text field.

Related

UIButtons pressed as Input for Text Field

Haven't found it on internet, searching on google I found Custom Keyboard as extension with is not what I need.
I need to make so that when you pressed my "Keyboard" on the bottom right (Its not actually a Keyboard, it is just a couple of UIButtons) the Inputs appear on the text field (Its the white space below ACTUAL CASH DEPOSIT).
So, when you press the text field, no keyboard should Appear, and When I start pressing the buttons of my "Custom Keyboard" the numbers should Appear.
I have found something similar in (Xcode 8 Swift 3). Using Custom Keyboard Extension with a particular Text Field But On my other Tap, Denominations I have multiple Input Fields. Like his image:
I know how to do all the code behind in terms of buttons pressed and calculations But I don't know how to make the input fields as a responder for my custom Keyboard.
You can't make it magically update - instead, I'd suggest binding all the buttons to a single function, and then then for instance use the tag property in IB to differentiate between them. Through that function update the text.
func didPressButton(button: UIButton) {
switch button.tag{
case 1: myTextField.text! += "1"
default: break
}
}
I'd caution you'll need to do some verification logic if you allow decimals so all numbers are valid.

Text Field Command (Objective-C)

I have a text field. When a certain text is in it, I want to run some code. But I'm confused on how to do this. Should I create an action for the text field, when the text is in it, and then create an else if with the name of the text field, and then the code I want when certain words are entered?
Have a look at the UITextFieldDelegate.
You could set the delegate of your textfield to a class that implement your custom actions in textFieldDidEndEditing.

Secure UITextField text change to (*) asterisk character

How can I change a secure UITextField text (which is simply a bunch of dots) to (*) asterisk characters like in the image below?
You can set it programmatically by
[textField setSecureTextEntry:YES];
or in IB (secured checkbox at the bottom)
You could also try simply implementing your own "secure text field".
Simply create a normal, non-secure text field, and link it's "Editing Changed" action with a method in your view controller.
Then within that method you can take the new characters every time the text is changed, and add them to a private NSString property, and then set the textField's .text property to a string with just asterisks in it (or any other character if you prefer).
Update: as noted by hayesk below, this solution is no longer ideal, as the introduction of third-party keyboards exposes input on any non-secure text fields to the third-party application, risking them collecting that information, and/or adding it to the autocorrect database.

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.

How do I set a UITextField as the default input field at app launch

I am writing an iPhone app with a keypad and two TextFields on a single view. The user types into each of the text fields. Because I want to use an on-screen keypad, I disabled the the keyboard from launching when each TextField is selected. (I used the method suggested in this thread:
Disable UITextField keyboard?
So far so good EXCEPT the cursor doesn't blink in the either of the two TextFields until they are selected. If I just begin typing without selecting, the first textfield is filled. That's OK, but I would like to set the cursor flashing in that field so the user is notified that that is where the input will go unless they select the other field.
I did not create the text fields programatically. I created them with Interface builder.
How do I programatically select the desired starting text field (ideally some highlight would show up when selected). Right now I just got lucky and the field I want to be the default is the default.
How do I place the flashing cursor onto the right side of that text field.
...Dale
Call [myTextField becomeFirstResponder]; this will notify the receiver that it is about to become first responder in its window. That should set the Cursor in the UITextField.
To programmatically activate a field and make it your starting text field you should use UIResponder's becomeFirstResponder method, which all UITextFields inherit from.
[textField becomeFirstResponder];

Resources