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.
-
If you dont see any paragraph set Word Wrap like here : http://stackoverflow.com/questions/30679370/swift-uibutton-with-two-lines-of-text – Nex Aug 16 '16 at 13:31
6 Answers
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.

- 9,289
- 12
- 69
- 108

- 23,007
- 8
- 61
- 83
-
1This doesn't work for all of them. I have about 10 UITextViews, all copy pasted, and some work, some dont. – t3hcakeman Jan 26 '12 at 16:50
-
What happens in the ones that don't work? Are they differently sized? – Graham Perks Jan 27 '12 at 05:31
-
1In the attributes inspector set property 'Lines' to 0 to have multiline label/text field. – Borzh Jun 03 '15 at 15:30
-
_works like magic_ [try this](http://stackoverflow.com/a/21654430/3577656) – Rajal Oct 20 '16 at 12:39
-
Don't forget to press 'enter' after done adding the newlines like me :) – Adam Johns Nov 20 '19 at 17:04
ALT + Enter makes a new line in storyboard

- 6,627
- 2
- 58
- 83

- 5,039
- 36
- 35
-
9Try not to use it. This will create special character . If you Open storyboard as Source Code the same editor deletes them, so you will need to edit all labels with line break again (XCode 6.3.1). Use Alt + Enter. – Borzh Jun 03 '15 at 15:29
-
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.

- 4,233
- 1
- 30
- 26
In the attributes inspector, there is property 'Lines' to set how many lines of text. Change it to 2.

- 10,182
- 20
- 95
- 162
- (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?

- 846
- 1
- 9
- 18
-
I didn't do any of this programmatically. This was all done in storyboard. – t3hcakeman Jan 26 '12 at 15:03
-
In my experience it is far more reliable to programmatically add text to a textview (if new lines are required) like this. It only takes a few seconds anyway. – Patrick Aug 08 '12 at 14:20