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 04-26-2011, 06:13 AM   #1 (permalink)
Registered Member
 
franium's Avatar
 
Join Date: Nov 2010
Posts: 68
franium is on a distinguished road
Default uitextview and newline: the text is printed all in one line

Hi all,
I succeed in printing the text contained in a uitextview (by airprint), but the text is printed all in one line, also if I use the return key in the textview, that is I begin a newline.
How could I resolve this issue?
Thanks,
Fran
franium is offline   Reply With Quote
Old 04-26-2011, 08:40 AM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Post code. You probably need to add newline characters.
baja_yu is offline   Reply With Quote
Old 04-26-2011, 09:02 AM   #3 (permalink)
Registered Member
 
franium's Avatar
 
Join Date: Nov 2010
Posts: 68
franium is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
Post code. You probably need to add newline characters.
I simply use the text property of the textview.

Code:
UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:self.myTextView.text];
If I use the return key, when I write in the textview, should it add a newline or not?
franium is offline   Reply With Quote
Old 04-26-2011, 09:15 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

yes, should work, NSLogging your string, you see it with newlines, right?
__________________
dany_dev is offline   Reply With Quote
Old 04-26-2011, 10:11 AM   #5 (permalink)
Registered Member
 
franium's Avatar
 
Join Date: Nov 2010
Posts: 68
franium is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
yes, should work, NSLogging your string, you see it with newlines, right?
Yes, I see the textview content correctly displayed on multiple lines.
So, what could be the reason for one line printing?
franium is offline   Reply With Quote
Old 04-26-2011, 12:44 PM   #6 (permalink)
Registered Member
 
franium's Avatar
 
Join Date: Nov 2010
Posts: 68
franium is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
Post code. You probably need to add newline characters.
The uitextview content contains \n.
The string is correctly displayed with NSLog.
Moreover if I use
Code:
UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:[self.myTextView.text stringByReplacingOccurrencesOfString:@"\n" withString:@"\n\n"]];
this resolves the issue, also if an empty line is duplicated.
For example, the string
Code:
First line
Second line

Third line
without the replacing it is printed as:
Code:
First lineSecond line
Third line
instead with the replacing:
Code:
First line
Second line


Third line
franium is offline   Reply With Quote
Reply

Bookmarks

Tags
airprint, new line, printing, 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: 348
11 members and 337 guests
dansparrow, iOS.Lover, lorrettaui53, Nobbsy, oztemel, pbart, PlutoPrime, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,897
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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