I have a UIWebView-based iPhone application that reads in HTML from a SQLite database. The user can save new information, entered via a UITextView that accepts carriage returns. How do I display these carriage returns (line breaks) properly in the UIWebView? I have tried using something like this:
NSString *HTMLData = [mySQLiteDataObject text];
HTMLData = [HTMLData stringByReplacingOccurrencesOfString:@"\\n"
withString:@"<br>"];
[webView loadHTMLString:HTMLData baseURL:nil];
But it doesn't look like the text is recognized as having line breaks: the text is displayed in one continuous line in the webView. When I print out the text in the console, it comes through with the line breaks intact.
I've tried using \n, \r and \r\n in the example code above, with no success. Am I saving the user's text incorrectly, or doing the wrong thing on the display side?