Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-22-2011, 01:44 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 12
josel_dev is on a distinguished road
Default 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?

Thanks.
josel_dev is offline   Reply With Quote
Old 09-22-2011, 02:01 PM   #2 (permalink)
Knows SQL
 
iisword's Avatar
 
Join Date: Oct 2009
Location: Somewhere the streets are on fire, the sewers are flooded, and the cats are high on catnip
Posts: 529
iisword is on a distinguished road
Default

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?
__________________
iisword is offline   Reply With Quote
Old 09-22-2011, 02:10 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 194
mavrik5150 is on a distinguished road
Default

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).
mavrik5150 is offline   Reply With Quote
Old 09-22-2011, 02:27 PM   #4 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 12
josel_dev is on a distinguished road
Default

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.
josel_dev is offline   Reply With Quote
Old 09-22-2011, 02:34 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 194
mavrik5150 is on a distinguished road
Default

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.
mavrik5150 is offline   Reply With Quote
Old 09-23-2011, 07:57 AM   #6 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 12
josel_dev is on a distinguished road
Default

Quote:
Originally Posted by mavrik5150 View Post
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.
josel_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
classic rock, multiple lines, uitextview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 396
14 members and 382 guests
7twenty7, eski, EvilElf, HemiMG, iOS.Lover, jarv, n00b, pbart, Pudding, sacha1996, Sami Gh, UMAD, VinceYuan, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,905
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:15 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0