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

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.

Related

Hide keyboard plus return key?

I have a view with a textfield at the top, a textview under it and two buttons below the textview.
The keyboard is configured with a "Done" button. Once the user has typed in their info, they click the save button, which is below the textview. First they click Done to hide the keyboard (and reveal the save button) then click the save button.
I need to allow carriage returns in the textview but "Return" is already taken up by Done.
How is it usually handled when you need a Return key and ability to also hide the keyboard?
Drag a button into your view, delete the text, and resize it to take up the entire view. In the document outline, select the new button and drag it to the top of the list of elements. This puts it in the background so it is not hiding the elements of your view.
Add this code to your ViewController:
#IBAction func hideKeyboard(sender: AnyObject) {
self.textField.resignFirstResponder()
}
Link the button to this action and you're all set.
If you're using a UINavigationBar or have other buttons or fields, activating any of those UIControls could be detected and used to dismiss the keyboard via resignFirstResponder(). In fact Save/Cancel/Done are UIBarButtonItems and are a standard mechanism for completing things and changing state, and create a framework for accomplishing what you want. If you don't take that approach then you have to get creative with how you do it, and also make it clear to the user what needs to be done.
In Interface Builder you can change the type of your main view from UIView to UIControl and then use addTarget() to detect touch events as a 'touch outside' area and use those actions to resign first responder as well. But you might want to consider a UINavigationBar or some other button bar or tab interface to make state transitions.
Also review iOS Human Interface Guidelines document. It's a great document for understanding how iOS is designed to handle common situations like what you are dealing with, and it can get you out of design ruts. It's well written and worth re-visiting periodically.

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.

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

Disable the Go button in the Keyboard for a UITextfield in iphone app

My app has a screen where keyboard is always visible. The main element of the screen is a UITextfield. For easy data entering, keyboard is always made visible. When the user finishes entering data and hits Go, the app performs a 4,5 seconds action which is done in the background thread in order to show UIActivityIndicatorView.
My problem is that the Go button on the keyboard still shows as enabled since the logic is performed in the background. The user could potentially hit the Go again causing it to run again.
I am not able to set editable/userinteraction properties to No because then the keyboard disappears. Is there anyway just to disable the Go button or freeze the keyboard until the background thread returns?
You clearly already have a UITextFieldDelegate set up to handle:
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField;
Otherwise, you would not be able to perform accordingly already. Just return NO from that function if the background process is running and the keyboard should not close. Example:
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (alreadyPressedGo)
return NO;
...
}
However, this will not "disable" the Go button, simply disable its functionality.
I've not tried it (not at an OS X box at the moment otherwise I'd give it a go), but I'm wondering if you couldn't effectively disable it by placing a touch receiving UIImageView or similar on top of it. (You could even set the opacity of the UIImageView accordingly to achieve a greyed out look.)
This is combination with the disabling the operation of the button as #Skyler illustrated should be ideal.

How do you launch a UITextView (iPhone) in edit mode?

I'm working on an iPhone app with only one view, a UITextView, and I want it to launch all ready for typing (with the keyboard activated) but by default it requires the user to first tap the view before the keyboard appears. I've seen this done in other applications but haven't been able to figure it out. Thanks.
you need to use the -becomeFirstResponder method on your field:
[myTextField becomeFirstResponder];
This will pop the keyboard up. To hide the keyboard, use -resignFirstResponder.