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

IosXcodeXcode4Ios5Uitextview

Ios Problem Overview


I am trying to make a new line in Xcode 4.2 UITextView, and when I do alt+return, it goes to the next line, but does not show up when built and ran.

Ios Solutions


Solution 1 - Ios

This works, I'm unsure what you are doing differently.

  • Drag out a UITextView.
  • Double-click it to edit text, place cursor where you want the paragraph break.
  • Option-Enter a couple of times to create a blank line & paragraph.

The paragraph shows at runtime. There's also a Text attribute that can be edited in the Attributes inspector.

Solution 2 - Ios

ALT + Enter makes a new line in storyboard

Solution 3 - Ios

In the attributes inspector, there is property 'Lines' to set how many lines of text. Change it to 2.

Solution 4 - Ios

This is a workaround, but it works everytime and also for UILabels which is more interesting:

Just open a text editor (e.g. textEdit or XCode itself), write the text with the new lines as desired, and copy paste into the Label text property in Interface builder. It shows in both, interface builder and runtime.

Solution 5 - Ios

- (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\n a line appart",self.theTextView.text];
}

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

I can give a more clear answer if you tell al wen exactly the new line must be made... Programmatically of when the user presses buttons?

Solution 6 - Ios

Drag a view (resize to a line) and add it a background color. I'm not sure if there's another way.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiont3hcakemanView Question on Stackoverflow
Solution 1 - IosGraham PerksView Answer on Stackoverflow
Solution 2 - IosMichal ZaborowskiView Answer on Stackoverflow
Solution 3 - IosDarrenView Answer on Stackoverflow
Solution 4 - IosFranMowinckelView Answer on Stackoverflow
Solution 5 - IosSimon BarkhuizenView Answer on Stackoverflow
Solution 6 - IosAdiView Answer on Stackoverflow