How can a USER enter multiple lines of text in my editable UITextView
This one has been troubling me and I haven't found a good answer.
I have a UITextView designed for the user to enter text, for something like a form. Most of the time it will make sense as multiple lines -- say the title is "Your 3 Favorite Songs"...the user will logically want to enter:
Back in Black
Welcome to the Jungle
Sympathy for the Devil
And not:
Back in Black Welcome to the Jungle Sympathy for the Devil
That would be done with a newline character, but the keyboard styles for UITextView don't seem to give the user the ability to insert a newline (not including copy/paste from somewhere else). They have Done. And they have Enter, which is processed in the same way as the Done...both resign the keyboard. OK, yeah, you can ALT-Enter in the UITextView when in the iOS simulator, but users don't use the simulator.
So what's the right solution? Is there a keyboard with Enter and Done that does what I need here? Or is this beyond the scope of UITextView? What other Apple UIxxxxxx or open-source modules out there might get me what I need?
Location: Somewhere the streets are on fire, the sewers are flooded, and the cats are high on catnip
Posts: 529
last time I checked, the developer was responsible for making the keyboard go away, otherwise the UITextView will do newline for the enter/done key. What method is your resignFirstResponder in for the textview?
I don't think you have to have the keyboard resign when the enter button is pressed, so instead of using [textView resignFirstResponder] to remove the keyboard maybe you can add the "\n" character to the textview.text. You may need to do some playing, like first grabbing the text into a MutableString and then appending the "\n" to that string then sending the updated string back to the textview. Also, because your doing this to replace the function of the enter key you would either need to add a navBar above the keyboard with the Done button that will dismiss the keyboard (I don't know how to do this but have seen it a lot in new apps).
Right, I don't HAVE to resign the keyboard in my delegate method. The issue is that I can't tell whether the user wanted an Enter/newline or a Done. They are both delivered to the delegates as newlines. This issue I think is really more about user experience/expectation than a technical limitation.
Well this is when you probably need to create the NavBar above the keyboard that will have the done button so you can have both options available for the user.
Well this is when you probably need to create the NavBar above the keyboard that will have the done button so you can have both options available for the user.
Thanks, that's what I ended up doing last night -- adding a nav bar with a DONE button, and then just use the Default UITextView keyboard (with a newline/return button). In this arrangement, the only time the textViewShouldEndEditing gets called is when I explicitly call resignFirstResponder from my new DONE UIBarButtonItem handler.
This works fine, it just really starts to shrink down the viewable size of the UITextView.