I want to disable the space character from the virtual keyboard on my iOS application when users edit an input text.
Users should enter a nickname. So I want to remove all space characters.
Thanks.
Trying to modify the standard keyboard requires taking a dangerous path into private APIs and a broken app in future iOS versions.
I think the best solution for you would be to implement the textField:shouldChangeCharactersInRange:replacementString: method of UITextFieldDelegate and replace whitespace characters with the empty string.
Once this is implemented, hitting the space bar will simply do nothing.
Related
As far as I can tell by default the react native text input component has some inconsistencies on iOS from the normal text input when using it in a controlled way. The examples I've found so far:
the "period shortcut" (pressing two spaces to get a period in text) does not work.
typing a special character and then space does not switch the keyboard back to its normal mode
spelling errors do not have a red underline
often text replacement shortcuts don't work
I'm trying to get around this in the short term and so far the only thing I've found that works is using a multiline input. At this point I'm trying to "hack" the multiline input to work like a singleline, but figured it was also worth reaching out to see if anyone else has a better solution.
I'm trying to implement the transfer of a one-time code from SMS to the field above the keyboard, as in the image.
But for some reason the field above the keyboard is not displayed.
Code:self.valueTextField.textContentType = UITextContentTypeOneTimeCode;
UI hierarchy:
+UIView
CustomContentView
UIImageView
UITextField - valueTextField
UITextFieldContentView
I have read these materials:soQuestion and apple docs , and I saw a warning:
If you use a custom input view for a security code input text field, iOS cannot display the necessary AutoFill UI.
... but I do not understand what is meant by custom input view.
Also I have category for UITextField. Can it affect the work?
I will be glad to any ideas, thanks!
Okay. This is what I could find out. Regarding the code, it is enough that I described above. Additional settings on the client is not required. But you need to pay attention to the text of the SMS message. As an example, I attached two messages.
In the first message, our code is defined by the system as a phone number. We can even call it if we click on it. But why do we need to call a one-time code? :)
In the second image, the code is defined as one-time, just what we need. If we click on it, the system will offer to copy it to the clipboard.
What is the difference? Unfortunately, it is not completely clear by what rule the text is parsed in SMS. But we can check your text in the following way:
If you set a property textContentType to your text field and nothing works for you, the first thing you need to check is whether the operating system determines the code correctly. To do this, simply go to the message application and check the code:
blue font color with underscore - the system did not recognize
one-time code.
black font color (as default) with a gray underscore - it's okay!
At the end, in the first case, you should check the text of the message for the contents of incorrect characters.
PS Just a couple of examples of correct and incorrect SMS:
SMS-code: 12345 £ correct
SMS-code: 12345 $ correct
SMS-code: 12345 № correct
SMS-code №1: 12345 incorrect
I got caught out by the fact "Autofill PAsswords" was turned off on the phone.
It seems that it needs to be on for this functionaility to work.
I have a TextInput that should only accept numeric values. I can more or less force this by using keyboardType "number-pad" on iOS, but Android only has "numeric", which provides keys for characters like - or ,. Even then, an attached hardware keyboard (like the iOS Simulator / Android Emulator have by default) still allows entry of non-numeric characters.
Everything I can find online is filtering the entered value in onChangeText, storing the filtered value in the state and use the state as the TextInputs value – while this does work, it causes the entered value to briefly appear before the JavaScript is able to filter it. Since I can't force the Android keyboard to only show numbers, I really want to avoid this visual behavior.
Android has android:digits for this, but I don't think this is available in React Native.
Is there any way to filter the TextInputs value before it is displayed?
I think solution for now is to accepts extra characters on Android and when you are submitting the form just transform that text field's input before sending to server :)
I'm beginning to learn Xcode and as the first app i decided to write a calculator. I did everything and it works pretty good but there is one thing i couldn't find. I want when the user writes Letters instead of numbers and taps the button , an alert appear and prevents him from entering letters.I'll appreciate you if help me and sry for my bad english.
If you don't want to allow the user to type letters at all you'll be much better off using the numeric keyboard. The decimal numeric keypad is available in iOS 4.1 and up, and you can find out more about it from this question:
How to use the new UIKeyboardTypeDecimalPad feature in iOS 4.1 SDK
As the comment said, you'll probably be better off just changing the input type of the keyboard.
[myTextField setKeyBoardType:UIKeyboardTypeDecimalPad] // has a decimal, use UIKeyboardTypeNumberPad for no decimal
See list of all available types here.
I've created a UITextView and set the autocapitalization property to UITextAutocapitalizationTypeSentences or to UITextAutocapitalizationTypeWords. Both settings work as expected except for the first word that is typed, which is not autocapitalized! It is autocapitalized if the user deletes the text taking the cursor back to the start of the line.
My workaround would be to convert the first letter from uppercase to lowercase in the UITextView delegate method textView:shouldChangeTextInRange:replacementText:.
The only tiny issue that remains is that the user is unable to tap on the shift key to prevent the first word from capitalizing.
Do other people experience this issue and is this what you've done?
Thanks.
I think this may be an issue with the simulator. It seems to be working fine on the device!