Entering/Clearing specific UITextfields? - ios

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.

Related

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

Drag caret between text views

I am displaying a text document using many UITextViews, one for each paragraph*. When the user drags the caret around it obviously stops when he reaches the beginning or end of a paragraph. Is there any way of letting the user drag the caret between text views as if all the text was in one text view? In a way that is allowed in the App Store?
* There is a good reason for this, at least if my proof-of-concept actually succeeds in proving the concept.
This would be a pain in the ass to implement, but going off this answer as an indicator of cursor-on-text:
how to get selected text from uitextfield in iphone?
Check the position of the cursor, and if it matches the length of text in a textfield, start a gesture listener, and if it moves down and right, change the focus to the next textview. Keep your textviews in an array for easy accessing.

Code input text field

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.

UITextVew tap in the middle of a word and place the cursor there

In the common behavior of UITextVew if the user taps in the middle of a word the cursor gets placed at the beginning of that word, or in other cases it selects the whole word.
I would like to entirely disable this and just let the user tap anywhere in the UITextVew and place the cursor just there.
Also I would appreciate to know if this is possible too for a UIWebView with contentEditable enabled.
Thanks in advance.
To get this behavior you have to build the text view yourself using core text. Or your only support iOS7. There you will have TextKit.

read-only Textbox

The form window(chat window) that i am creating for a lan messenger is similar to the one in google talk with two textboxes. What i need to do is to transfer characters typed in the lower textbox(textbox2) to the upper textbox(textbox1 which is read-only) when i click the submit button without showing that textbox1 is read-only because the characters are appearing in grey.please help with code if possible.
Use a label for this instead of a textbox. If the only thing it is doing is display the characters and not a direct edit, you won't lose any functionality and the text would not be greyed out...
If you're going to use a Texbox, set it to Locked. That shouldn't gray the characters out. Otherwise in KeyDown/KeyUp events, set the e.Handled property to true (which will tell the box that you want to handle the input yourself and don't want the message to filter down).
That oughta do it for you.

Resources