iPhone UITextField Keyboard Space Switching Layout - iphone

I want the user to be able to type in only numbers and spaces. I set the keyboardType textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; but if a user hits space, the keyboard layout switches to letters.
So the user has to switch after each space to the number layout which I want to stop.
I know I can stop entering any spaces by the textfield delegate method shouldChangeCharactersInRange or or the NumberPad Layout but I want the spaces to display.
Is there a workaround for this?

Potentially you could use the keyboard layout suggested here but instead of a "Done" button you could include a "_" spacebar button? This has the added benefit of preventing the user from selecting any punctuation.
An alternate answer to specifically the behavior you're seeing is found in this other post.

Related

Restrict the TAB key on accessory keyboards

I have a UIScrollView with 2 views, side by side, each of which covers the entire screen.
They are moved to visible bounds on user's action, only one covering the screen at a time. Both of these views have multiple UITextFields. Working with the simulator, I fill in a textField in the first view and when I press the Tab key, the firstResponder is assigned to a textField in the other view. I understand that on using the device, the user will not be able to do that. But what if the user uses a bluetooth keyboard, or similar accessory? I do not want a textField, that is currently not visible to become firstResponder. Can this be done?
EDIT: I just remembered the canBecomeFirstResponder method. But how do I determine which textField is about to becomeFirstResponder?
It sounds like the problem isn't that they shouldn't be able to tab between the two text fields, but instead that they shouldn't be able to edit a text field that isn't visible, and they should be able to tab between them if they are both visible at the same time.
Instead of restricting tab, I would implement the UITextField delegate method -textFieldShouldBeginEditing:, which allows you to return a boolean whether or not that text field should become the first responder.
Something such as:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
// Only edit if the text field is visible
return !textField.isHidden;
}
You may need to adjust this code to fit your 'is visible' status of the text field.

insert chinese handwriting keyboard into view of app

i would like to sort of embed the chinese handwriting keyboard into a view in my app. That is to say, i don't want it connected to the real keyboard. In fact, I don't even want it visible to the user. I'd like the user to simply be able to handwrite in the center of a blank screen, and have a chinese character output on the screen after completion. is this even possible?
The only way you could support handwriting would be to write a view which never became firstResponder (preventing the keyboard from appearing), userInteractionEnabled=YES (to get touches), and uses the touchesMoved to draw the characters as the user moves their finger.
You can implement a custom keyboard by returning a custom keyboard UIView from the inputView property on UITextView and similar text input views.

Removing a Keyboard after text is entered into a TextView

I have made a text view in interface builder and when i type in my details into the box, clicking done doesn't minimise the keyboard.
How is this done?
Thanks
UITextView does not have any methods which will be called when the user hits the return key. If you want the user to be able to add only one line of text, use a UITextField. Hitting the return and hiding the keyboard for a UITextView does not follow the interface guidelines.
Even then if you want to do this, implement the textView:shouldChangeTextInRange:replacementText: method of UITextViewDelegate and in that check if the replacement text is \n, hide the keyboard.
http://iosdevelopertips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html
How to dismiss keyboard for UITextView with return key?

How to keep UIKeyboard when textfield is regisned first responder?

I'm writing an app that has a view similar to the SMS app's text editing view. It has a textview on the top and a textfield on the bottom. I want to allow users to copy and paste texts in the textview while keeping the keyboard appear. But if I try to copy the text, the UITextField will resign first responder and the keyboard will missing. Any ideas about how can the SMS app keep the keyboard while user is copying texts in another view?
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
return NO;
}
I've tried to return NO for -(BOOL)textFieldShouldEndEditing: , but the textview to the upper cannot copy text then.
Related Option:
Just Give a button on Topbar or anywhere else that have option to copy the text then its more user friendly..
Second Option:
If you have much good know programming concepts then just create the new view above the keyboard and animate when keyboard is show and don't resignfirstresponder, and following options are their, copy text, done, in the done action you have resign first responder
Those are only option which u have done if you want more userfriendly app because in appStore and appReview Department have verify the User Convenience UI Integrations and you must full fill that and from the other side user's whom purchase or download the app also give the awesome comments on the app who is more reliable and cashless functionalities ....
I've tried to return NO for -(BOOL)textFieldShouldEndEditing: , but the textview to the upper cannot copy text then.
add a textfield so it can scroll and set the dimentions or just add the scrollbar to scroll it to .. it will solve your problem

UITextView with "Done" button *and* "Return" key?

I use a UITextView for multiline text entry in my iPhone app, and I have set the "Return" key to display "Done." I've also set up the return key to disable first responder status, so that hitting "done" actually exits the UITextView. However, I also want to enable users to be able to enter multiline text into the UITextView, i.e. to be able to use the "Return" key. Is there any way to make this work on the iPhone/iPad's UI?
I've been struggling with this issue for 5 years waiting for apple to wake up and create some sort of solution for the textfield multiline responding to done button until I decided to create one myself.
there you go:UITextField multiline with hide keyboard option
It'll be time consuming but you could create your own keyboard with both these keys (this can be done by specifiying the Input View for the UITextView ).
Another alternative could be having a button that sits just above the keyboard that would dismiss the keyboard. You can use the UITextView's Input Accessory View which allows you to create a view that sits on top of the keyboard. See here for more information (I'm aware this document is for iPad but it works for all iOS devices - also just to note, both these require iOS 3.2 or greater).
This should only need to be done on the iphone because the iPad keyboard already comes with a dismiss keyboard button as well as a return button.