iDev
iDev

Reputation: 2433

iOS 5: How can I preserve newline while retrieving values from mysql via PHP in UITextView and UIWebView

I am retrieving values from mysql database (using PHP) and displaying it in UITextView and some portion in UIWebView. The Values that I had stored in database were in TEXT but when I display it in UITextView the data which I want to display in points gets displayed as a paragraph. How can I make a newline since the data that I receive is already in a NSString

Upvotes: 2

Views: 672

Answers (2)

iDev
iDev

Reputation: 2433

Thanks, I was able to do it, using the following code :

NSString *myNewLineStr = @"<br />";
string = [string stringByReplacingOccurrencesOfString:@"\n" withString:myNewLineStr];

Upvotes: 2

MANIAK_dobrii
MANIAK_dobrii

Reputation: 6032

UITextView puts a new line on \n, UIWebView shows html and if you have just a plain text with some links or something, you may add a <br /> for a new line. So in order to preserve line breaks for UITextView you need \n and for UIWebView valid line-breaking-HTML (for example <br />).

Not sure why you're getting a paragraph, maybe you over-escape or something in you php routines?

Upvotes: 2

Related Questions