How to replace UIPickerView with native keyboard back? - ios

I need to dynamically change the input for UITextField: keyboard with pickerView and back (pickerView with keyboard).
I know how to substitute keyboard with pickerView - via input property of textfield.
But I don't know to substitute pickerView with keyboard back. How can I do this?
The flow is following:
user need to enter some value into textfield (typing via keyboard)
then I'll show them some clarification options via pickerView, user select any option and it will appear into textfield
then user should be able to edit the selected value in the textfield via native keyboard
Thank you

You can use,
textfield.inputView = nil;
and if you want to show keyboard directly after then you can use
[textfield becomeFirstResponder];
Hope this will work. :)

Related

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!

Disabling enter button in iOS keyboard

I have an iOS keyboard question.
Say we have a UITextField (let's call it textfield) and a standard virtual keyboard, with the Enter key set to Send. We'd like to disable the Send key when UITextField is empty, otherwise enable it. We have set enablesReturnKeyAutomatically to YES on the text field. This works fine when we manually edit the text in the text field.
However, the Send key doesn't seem to work fine when we programmatically change the text. Our app will clear the text field by calling textfield.text = #"" once the Send key is hit and the text is sent. In this case, we expect the Send key to be disabled since textfield's content is empty. But no -- it appears enabled.
We want to disable the Send key in such a case. Please share your experience if possible.
Thanks!
I think the best you can do is to ignore the return event this way:
- (BOOL) textFieldShouldReturn:(UITextField*) textField {
return textField.text.length > 0;
}

UITextField keyboard: enable done button when no text is entered

I have a UITextField in my app. When the user selects it, a keyboard is presented with a done button. The keyboard is dismissed by pressing the done button. But the done button is only enabled after the user has entered text. I want the user to have the option of dismissing the keyboard without entering text. Is it possible to enable the done button before text has been entered?
OK, I discovered this is resolved by unchecking the Auto-enable Return Key property in the Attributes Inspector.

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];

How to programmatically set iphone keyboard to show desired key set

I am programming an iPhone app that I want a text field where the user can add numbers from the keyboard and add them on the fly, ie, the user might type "1.5+2.4+6.3+.063" and as the user types additional numbers and plus signs the total is displayed immediately.
The problem is starting on and keeping the keyboard in the 123 mode after the user types a + sign (using email keyboard because it has the numbers and the plus sign on the same view).
How can I start the email keyboard on the _123 screen and keep it there?
Thanks! Mike
use below code to set the keyboard type
myTextField.keyboardType = UIKeyboardTypeNumberPad;
All the keyboard type is define in UITextInputTraits protocol, which is implemented by UITextField
Depending on what textfield you want to set it for you go:
[textField setKeyboardType:(UIKeyboardType)];
Where UIKeyboardType could be any of the following: UIKeyboardTypes
***EDIT
In your case you would do:
[textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
***EDIT
No, I could not find a way to programmatically change keyboard modes to 123 or #+=.
But if you want the default keyboard start as if user had pressed the 123 button on keypad, your only choice is:
textField.keyboardType = UIKeyboardType.numbersAndPunctuation
Here is how numbersAndPunctuation keypad will be presented
Other related/useful keypad types are:
textField.keyboardType =.numberPad
textField.keyboardType =.decimalPad
textField.keyboardType =.phonePad

Resources