How to make a new line in a UITextView in a nib / storyboard?

I am trying to create a new line in Xcode 4.2 UITextView, and when I do alt + return, it goes to the next line, but does not appear when building and starting.

+55
ios xcode xcode4 ios5 uitextview
Jan 26 2018-12-12T00:
source share
6 answers

It works, I'm not sure what you are doing differently.

  • Pull out a UITextView .
  • Double-click it to edit the text, place the cursor where you want to break the paragraph.
  • Option: enter a couple of times to create an empty line and paragraph.

This paragraph is displayed at run time. There is also a Text attribute that can be edited in the attribute inspector.

+121
Jan 26 2018-12-12T00:
source share

ALT + Enter creates a new line in the storyboard

+36
Feb 11 '15 at 9:04
source share

In the Attributes Inspector, the Lines property exists to set how many lines of text. Change it to 2.

+3
Jan 26 '12 at 15:09
source share
 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //Note: the \n created a new line. //This piece of code assumes there IS ALREADY text in the theTextView self.theTextView.text = [[NSString alloc] initWithFormat:@"%@ \n\na line appart",self.theTextView.text]; } 

Assuming you created "theTextView" in a file (.h) and synthesized it in a file (.m) and made the appropriate connection.

I can give a clearer answer if you say that a new line should be done ... Programmatically, when the user presses the buttons?

+1
Jan 26 2018-12-12T00:
source share

This is a workaround, but it works every time, as well as for UILabels, which is more interesting:

Just open a text editor (for example, textEdit or Xcode itself), write the text with new lines as desired, and copy it to the Label text property in the interface builder. It is displayed both in the interface builder and at runtime.

+1
Jul 08 '16 at 18:04
source share

Drag the image (resize to line) and add it to the background color. I am not sure if there is another way.

0
Dec 08
source share



All Articles