Text Field Command (Objective-C) - ios

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.

Related

How to move placeholder up while typing in the textfield? is it possible just from storyboard? or code in IOS Objective-C?

I have set the values of placeholder
self.baseURLTextField.placeholder = ServiceUrl_English;
self.paymentBaseURLTextField.placeholder = PAYMENTSERVICEURL_ENGLISH;
I just want to move the placeholder up while editing or typing in textfield. is it possible through just only storyboard? or code in Objective-C.
Not really the way you intended it. Placeholder is just a hint of what should be typed in the textField and it's supposed to be removed once text entry starts.
If you want the placeholder to "move up" I suggest you either prefill the textField with the text you want to preserve, or simply add the text at the point user starts typing in, and move the cursor to where you want the user text to start.
You can achieve this by putting a UILabel at the top of the text view then show/hide it whenever the user starts typing.
Or you can use a pod like JVFloatLabeledTextField

How do you reference the input text from a UIAlertController's Text box?

I have a text box within my alert controller in which the user puts in the what they would like to save the object as. I cannot find a way to reference this string the user puts in.
UIAlertController has a textFields property which retains an array of UITextFields used in your alert controller.
Use this property to access the text fields displayed by the alert. The text fields are in the order in which you added them to the alert controller. This order also corresponds to the order in which they are displayed in the alert.
If you have only one UITextField, you can use [alertController.textFields firstObject].text to access the text entered by the user.

Xcode: Text Field to String

I'm new to Xcode and trying to do something easy.
But unfortunately, I couldn't find an easy way to do so.
My question might be (laughably) easy but I'm seriously stuck right now.
In Xcode, there is an object in the object library called "Text Field".
In this text field, words can be entered. I want to push a button and save the written words not a string, which I can then display as a label.
Help would be really appreciated.
Thanks in advance!
The "Text Field" UI element in the object library represents an instance of a UITextField. If you look at the documentation, a text field has a text property - a String that contains the current textual content of the text field. Similarly, UILabel has a text property. So you want to take the text field's text, and assign it to the label's text.
Assuming you have an outlet to your text field in the storyboard and an outlet/variable referencing the label you want to set the text of, in your button's action method, you might do something like this:
#IBAction func buttonPressed(button: UIButton) {
myLabel.text = myTextField.text
}

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.

How to select a UITextField without showing UIKeyboard

I am wondering if there is a way to use a UITextField programatically (i.e. use buttons as inputs) so that you can select a UITextField but not show the UIKeyboard, then when you select a UIButton it would assign a string value to the currently selected UITextField.
I don't really know where to start.
I think you can visually change the appearance of the text field (for example add a blue border), let the user feel it’s “selected”. Then you just modify textfield.text when user presses button.
Or alternately, you can create a customized keyboard. There are many similar questions.
It seems that you don't really need a text field (e.g., edit/select text, etc.), but a "button that stays highlighted" instead. Then, you can programmatically change the button's title label to the specified string when the user taps the 'proper' buttons.

Resources