I have a textfield and I would like to remove the punctuation marks from the keyboard and also the spacebar. Can this be done?
AFAIK, you cannot remove anything from the keyboard without providing your own custom keyboard. You may however, intercept characters before they appear in the textfield using it's delegate method -(BOOL)textField: shouldChangeCharactersInRange: replacementString:. (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextFieldDelegate_Protocol/index.html#//apple_ref/occ/intfm/UITextFieldDelegate/textField:shouldChangeCharactersInRange:replacementString:)
Related
Currently I am walking through my whole iOS app to optimize it for accessibility voice over. When it comes to the UITextView, which I subclassed, voice over is not acting like I thought it would. My UITextView subclass is only changing a path's color on the superview's layer in becomeFirstResponder and resignFirstResponder. So nothing special on my UITextView subclass that could interfere with accessibility.
As long as there is no text in the UITextView it is acting as expected. Voiceover tells me that it is a text field and that I can double tap it to edit. But as soon as there is text in the UITextView, the only thing voice over tells me, is the value of the UITextView. Voice over doesn't tell me anymore that this is an editable text field.
Am I doing something wrong? Why is it acting like that?
I do appreciate any help!
If you didn't edit any accessibility hints or labels for the text field it should act accordingly. If selected it should say:
It is a text field
If you are editing it
The editing mode you are in
The value of the text field (nil if empty)
Where the cursor is
Then while you type it says the letters you are entering as you enter them. When you hit space or enter it should say the word you just typed. As long as your text field is exhibiting these behaviors you should be fine.
Tip: if you want to know how accessibility elements should act, try using a native iOS app with accessibility turned on and compare it with your app.
The problem I have is that I want to detect when the UITextField's text is being changed when the user taps on autosuggestion word.
Using textFieldShouldChangeTextinRange will also react to pasting any text from clipboard, but I want to process EXACTLY the autosuggested text replacement.
It is not possible, there is no UITextfield's delegates to implement it.
I have a textfield that can switch between a numpad and an alphanumeric keyboard (for design reasons). Here's the code:
self.tfID.keyboardType = UIKeyboardTypeAlphabet;
[self.tfID reloadInputViews];
The problem is that when I switch from numpad to alphanumeric, it doesn't automatically turn on the caps even though that field is set to UITextAutocapitalizationTypeAllCharacters. I don't want to do this through the delegate because I want to still allow the user to enter in lowercase characters if they choose so. Is there a way to do this?
Edit: After the first character is typed, the caps lock is turned back on so only the first character is lowercased.
I have tried this and it works. Instead of calling reloadInputViews on your textfield, if you call resignFirstResponder immediately followed by a becomeFirstResponder on your textfield it will auto switch to all caps again for the first character. This does slightly show the animation from lower case keys to all caps keys, but it does achieve your functional goal of getting back to all caps automatically for that first character.
self.tfID.keyboardType = UIKeyboardTypeAlphabet;
[self.tfID resignFirstResponder];
[self.tfID becomeFirstResponder];
I have UiTextField, when editing I change keyboard to emoji. then I go back and open another text view from another screen. but it shows emoji keyboard instead of default keyboard. please help me to fix this issue. thanks
I don't think you can fix it. It's up to the user to decide what keyboard they want visible and the setting applies across all apps, not just within your own app.
Please set the keyboardType for the UITextField
[textfield setKeyboardType:UIKeyboardTypeAlphabet]
You may look at the Apple's documentation to see in detail for keyboard implementation.
Set keyboard types
[textField setKeyboardType:UIKeyboardTypeEmailAddress];
These are the keyboard return types,
UIKeyboardTypeDefault,
UIKeyboardTypeASCIICapable,
UIKeyboardTypeNumbersAndPunctuation,
UIKeyboardTypeURL,
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeDecimalPad,
UIKeyboardTypeTwitter,
UIKeyboardTypeWebSearch
Check Apple Libaray , Input KeyBoard Types
I have a UITextView which the keyboard enters values into. However, if you clear the text value (i.e uitextview.text = #""), the keyboard's state does not reset to the lowercase alphabet keyboard.
That is, if I was in the middle of typing "hello.." and the textview gets cleared, the keyboard still shows the symbols, rather than back to the alphabetical letters.
Is there a way to get around this?
It turns out
[textview resignFirstResponder]
immediately followed by
[textview becomeFirstResponder]
does the trick. It does seem a little "hacky" though, but with Apple not providing any direct access to the keyboard, it seems that this is the only way.