Conversion between any string and \ n

Source: Internet
Author: User

Recently, I am working on a chat software that writes multiple lines of text copied from others. How can I keep the line breaks of the three lines of text intact.


For example, paste the text into the chat box, and then only the first line of text is left.





Copy it to the chat box, and only the first line will be ignored.




-(Void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view. // set <br!> Change to \ n nsstring * string = @ "123 <br!> 456 <br!> 789 "; nsstring * newstr = [String stringbyreplacingoccurrencesofstring: @" <br!> "Withstring: @" \ n "]; nsstring * newnewstr = [newstr stringbyreplacingoccurrencesofstring: @" \ n "withstring: @" <br!> "]; Uilabel * label = [[uilabel alloc] initwithframe: cgrectmake (10,100,100,200)]; label. backgroundcolor = [uicolor redcolor]; label. TEXT = newnewstr; // the following code is very important and very important label. numberoflines = 0; [self. view addsubview: Label];}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.