Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert new line \n from UILabel text which typed in IB? [duplicate]

I have id textInput and I insert new line(\n) OK with:

[textInput insertText:@"\n"]; 

But when input Text from label.text (Input in Interface Builder) ,it NOT OK. Just input \n text.

NSLog(@"%@",label.text); [textInput insertText:label.text]; 

How to input special character when store it in label.text?

I don't want to compare [inputStr isEqualToString:@"\\n"];

*Log: \n

Thanks!

like image 427
Alex Avatar asked Mar 16 '13 02:03

Alex


People also ask

How do you add a line break in UILabel?

To add line breaks in the text we'll use \n character in the string we want to assign to the label.

How do you wrap text in UILabel?

If you set numberOfLines to 0 (and the label to word wrap), the label will automatically wrap and use as many of lines as needed. If you're editing a UILabel in IB, you can enter multiple lines of text by pressing option + return to get a line break - return alone will finish editing.

How do I change the UILabel text in Swift?

To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.


1 Answers

Try option-return or pasting in the newline.

like image 75
tc. Avatar answered Oct 15 '22 13:10

tc.