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?
Related
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.
I want to add the smilies in the keyboard for text to add the comment like :P and <3 and if I did so to create the custom keyboard, will Apple reject my application?
You can add simple UIView with buttons above the keyboard, and show this view when keyboard appears. By pressing buttons just insert corresponding smiles to text.
if you are using something like UITextField, you can simply create a UIView with buttons like ":P",and assign this view to UITextField's inputAccessoryView property.
I am developing a program in which I have UITextView in that I need a cursor without the key board.In this cursor is show only with the keyboard if I hide the keyboard cursor will also get hide.How can I get the cursor without the key board ?
The cursor is displayed as long as you UITextView is being edited.
Thus, you can change its inputView view to some other view if you need to, and it will be displayed instead of the keyboard.
See http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIResponder_Class/Reference/Reference.html
With this method you can add your custom inputView, a UIPickerView for example, or as you say you want you can add a minimalist hidden UIView.
If you want to restrict UITextField content, you still need to implement UITextFieldDelegate, as the user can still paste content to your text field!
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
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.