Universally restrict UITextfield input - ios

How can I restrict input to alphanumeric app-wide? Do I need to subclass UITextField? Can I set that attribute in the appDelegate?
Edit: I'd like to avoid using keyboardType ASCIICapable. Client would like to keep the email keyboard, etc. functionality.

try playing around in the storyboard
.
navigate to KEYBOARD TYPE setting and see if it has the requirement you need.

Related

Custom Keyboard on iOS

I need to create a custom keyboard for my app, but no sure the best way to do it without the user needing to add a keyboard in the settings. If I create a keyboard extension is it possible to set a UITextField's Keyboard Type to that custom keyboard? Or will I have to use a UIView to accomplish this?
For a custom keyboard that is specific to a single app, create a view and assign the view to UITextField.inputView:
textField.inputView = YourCustomKeyboard()
In my search I didn't find a way to tack on additional keys but there are examples of custom keyboards using inputView that are easy to adapt.
A custom decimal keyboard example
My hexadecimal keyboard version
You can add accessoryView to text view for you want to give a few extra buttons.
If you still looking for some more then please go through the below link.
https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=keyboard

Misuse of UITextField.inputView to get similar popup behavior of keyboard

I often want to put my own things in the same place the keyboard pops up, but for my own controls... such as putting a UIDatePicker there, or a custom UIPickerView, or whatever.
I came up with a clumsy way of getting this behavior by having a dummy UITextField and putting my custom view in its inputView property. Then when the user clicks on my item, I just trigger off the UITextField to display the view I've assigned to the inputView.
Then I got to wondering if there was a better less kludgey way to do this. I found this article Show UIPickerView like a keyboard, without UITextField where several people recommend the same thing I do.
My question is this. Is it common to (mis)use the UITextField in this manner?
Many times you will face a UITextfield that you would want to populate through a custom control other than the standrd keyboard. Thus the inputView method was declared and can be used.
What is recommended:
1- if the UItextfield is normal, use the keybard (don't change the input view)
2- if the value is numeric, show the numberpad in keyboard directly (textField.keyboardType = .numberPad)
3- if your textField is a date then you set the input view as a date picker.
4- sometimes you need a UITextField where you need to choose between stuff. Thus you develop your own custom UIPicker and set it as an input View.
5- If what you are tring to achieve don't fall in all the above then you can do your own inputView and assign it.
So in short don't be afraid, it is the normal thing to do!
Hope this helps!

Is it possible to add a Done key to ALL keyboards in an app?

Is it possible to add a done or cancel key which dismisses a keyboard to all keyboards in an iOS app? There are several posts asking how to dismiss a keyboard via a cancel or done button, but the solutions are on a field by field basis.
Are there any solutions that add this functionality globally so the code wont need to be duplicated for each textfield/area in an application?
Like #silentBob says in his answer, the inputAccessoryView of a text field is the view that’s displayed immediately above the keyboard when the text field is the first responder. If you didn’t want to write an extension on UITextField to override the -inputAccessoryView method, you could also create a subclass of UITextField to do the same, which would make it easier to determine which method is going to be called. You could also have multiple subclasses of UITextField to customize which button(s) appear. If you have a text field in a storyboard, you can simply change the class to your custom subclass, so while you have to go through and make those changes, you don’t have to do it in code.
Yes, you can add an extension to UITextField class, which should add a UIToolbar with Done and Cancel actions as UITextField inputAccessoryView.
Well, In that case you have to customise the keyboard, built your own keyboard and do whatever you need to do with your key in the keyboard.

Customize uikeyboardtype with #gmail.com and numbers

I want to create a UIKeyboard type that will look like the following.
This app is only for iPad and none of the default keyboard type seem to match.
Any suggestions for adding buttons to the keyboard type?
I may be wrong, but what that looks like is the standard keyboard with a custom toolbar on top. It was most likely done using the inputAccessoryView property for the textfield:
[textField setInputAccessoryView:inputAccView];
Here is where I took the example from.
As far as I am aware, this is not supported in a super easy way by default iOS system keyboards.
However, you can specify your own UIView as an "input accessory view" for a text field.
Specifically, look at this method in the UITextField documentation:
inputAccessoryView.
So you should just be able to create a UIView, style it to look very similar to the usual system keyboard UI, add UIButtons, and set it as the "input accessory view"
But you will have to do your own work to make the background of the accessory view and the buttons on it fit well with the system keyboard.

how to add a custom key to Keyboard in ios?

I want to add a custom key to my Keyboard. (a .com key) When user begins to type in email text field this keybord with the key should be appeared. I used keyboard type email. But it not gives that key. How I can add this key to my keyboard.
Thanks
Here is the tutorial that helps you add custom buttons into ios keyboard!
adding-custom-buttons-to-ios-keyboard
The .com key is added when the URL type keyboard is used: KeyboardManagement
You might as well make use of the inputAccessoryView of the text field, add a UIToolbar to it, and in the toolbar you can add a few buttons you want, including custom .com button.
Have a look at this: custom keyboard
Integrate one of them into your project and customise it accordingly. Hope it helps to start...
There is no way you could change default keyboard. and If you anyhow modify it(using private methods) apple will reject your app because it is against apple guidelines.
So the only solution to your problem is create a custom keyboard and then use it.
There are few custom keyboards you can use them also :
custom-ios-keyboards
ioscustomkb
how-to-create-a-simple-keyboard-with-custom-navigation-buttons
Hope it helps you.
You can't change default keyboard of Apple.
But you can select with keyboard type for UITextField or UITextView by set some properties in UITextInputTraits protocol. With email, set to:
[textView setKeyboardType:UIKeyboardTypeEmailAddress];
You can use inputAccessoryView to add some custom keys, refer:
dmforminputaccessoryview
Last option is create new Keyboard (UIView subclass) and set it to inputView of UITextView or UITextFied:
Custom-iOS-Keyboards

Resources