I have a UIWebView-based iPhone application that reads in HTML from a SQLite database. The user can save new information entered through a UITextView that accepts a carriage return. How to correctly display these carriage returns (line breaks) in a UIWebView? I tried using something like this:
NSString *HTMLData = [mySQLiteDataObject text]; HTMLData = [HTMLData stringByReplacingOccurrencesOfString:@"\\n" withString:@"<br>"]; [webView loadHTMLString:HTMLData baseURL:nil];
But this does not look like the text is recognized as having line breaks: the text is displayed in one continuous line in the webView. When I print text in the console, it goes through line breaks.
I tried using \ n, \ r and \ r \ n in the above code example, without success. Am I storing user text incorrectly or doing the wrong thing on the display side?
source share