iOS 14 UIDatePicker - allow user to clear value - ios

Within our iOS app, we would like to give the user the option to use the UIDatePicker control but ALSO be able to clear the value after selecting it (the field allows a date OR a blank as the date is optional)
Other than change the field to be a UITextField to be able to add the clear button, is there a native way to add a clear option to the UIDatePicker? I have visions of a dustbin/trashcan on the control

Related

SwiftUI - make Picker default value a placeholder

Is it possible to set a placeholder text for a Swift Picker? I've been trying to search for a helpful answer but I haven't been successful so far, so hopefully this will help in solving the issue :)
Currently when passing available list values to the Picker I also pass it a default value to start of with. However, this default value is treated the same as if the user picked it. What I'm trying to achieve is that the default value should be grayed out (like regular placeholders for standard textfields) and when the user opens the picker that value would 'dissapear' as default forcing the user to pick something from the list (but without losing the range) - so f.ex. if I have a picker for values between 1-200 and I set my placeholder to 100 the picker would Still show this value when you open it (to avoid scrolling from the beginning) but it wouldn't be directly taken as the target value unless the user actually selects it.
A Menu may be a better option than a Picker in this instance.
Menu("Label") {
Button("Menu Item", action: menuAction)
Button("Other Menu Item", action: otherMenuAction)
}
Menu Documentation

Hide TextField selection handles

Im my application when the user selects a TextField the existing text gets automatically selected when the Focus changes to the textfield. How do I hide the blue selection handles that appear?
The reason I want to automatically select the existing text is so that the user can begin typing and the textfield will automatically overwrite the existing value instead of appending to it.
I figured it out. You can set the enableInteractiveSelection property to false.

How to set number side as default (while keyboard is open) of name phone pad keyboard type

Right now when the keyboard launches on my application it defaults to the letter side showing an alphabetical keyboard.
Question will be listed below images
Refer to image below:
This is good. Clicking 123 will show the number side.
The Question:
However, I want to by default show the number side and still be able to switch back to the letter side later WHEN THE KEYBOARD IS OPEN. How do I do this?
Setting the keyboard programmatically to a different type is NOT the answer!
For example: User clicks in the text field, keyboard pops up and defaults to let's say the ABC side. The user can click 123 to switch. This is what I want. If the ability to switch while the keyboard is open is taken away it defeats the point of this question.
So if the Name Phone Pad keyboard defaults to the ABC side initially. I want it to default to the 123 side that way while the keyboard is still open it can switch to ABC again when the user clicks ABC.
I want to do this because I have different settings for how to search for barcodes. Either by name of the product or number based on settings the user set about how to index results. This way if they are sorting by number it suggests numbers first, BUT they can still go back to searching by alphabetical if they wanted by clicking the ABC button on the keyboard.
Here is the current setting for my keyboard.
keyboardType is property for a UITextField.
textField.keyboardType = UIKeyboardType.UIKeyboardTypeNumberPad
and
textField.keyboardType = UIKeyboardType.UIKeyboardTypeDefault
is how you can switch between the two modes programatically. Hope that helps.
To switch the Keyboardlayout programmatically you have to mutate UITextfield's keyboardType attribute.
Try
textField.keyboardType = UIKeyboardType.NumberPad;
or
textField.keyboardType = UIKeyboardType.PhonePad;

Swift ios8: How to make single row picker with option for manual text entry?

I would like to give my iPhone App user the option of whether to use a picker (i.e., scroll wheel) or keyboard to input the value of a field. I'd like it to where the current value of the field effectively displays as isolated text (i.e., as a label, with the picker and keyboard hidden). But the user can change the field's value by either (A) performing a single tap on the label to reveal the keyboard so the user can type in a different value; or (B) perform a swipe on the label to reveal the picker so the user can user the picker to change the value. This will present a very clean interface in my opinion, without the clutter of the keyboard, text field, or picker unless the user changes the value. Help?
This control doesn't exist, but a possible solution would be to add a cell under the UIPickerView (assuming your using a table form) when the "Custom" option is selected and add a text field to that cell allowing custom input. Make sure you hide the cell if the UIPickerView value changes from "Custom" to avoid user confusion.

How do i resign the keyboard from a text field in my app settings

IOS xcode, in my root.plist i have 3 text fields. The user is able to change the strings for these fields which then saves in the nsUserDefault. While in the app settings page if the user click on the field to edit it the keyboard pops up. when they hit return focus moves to the next text field. Moving the focus off the text fields does not resignFirstResponder.
Since this is the Apple Settings page I don't have a way to assign view controller to create my method to resign the keyboard.
How do I resignFirstResponder from the app setting page.
you won't be able to do that...settings is a native *iOS* app..apple does not provide return in the text fields there..user has to navigate back...to hide the keyboard

Resources