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.
1
2
3
Copy it to the chat box, and only the first line will be ignored.
Code:
-(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];}