jdl
jdl

Reputation: 6323

How to goto the next line in UITextField?

In NSTextField all I have to do is add '\n' i.e.. @"hello\nthere" will be 2 lines:

hello
there

I tried this in UITextField and it all stayed on one line

hello there

What do I need to do to make text go to the next line?

thx

Upvotes: 2

Views: 723

Answers (3)

Rayfleck
Rayfleck

Reputation: 12106

If you are supplying the text and the user doesn't need to edit it, use UILabel, and set it's property

 numberOfLines = 2;

If the user does need to edit it, use a UITextView, and set it's frame.size.height to be at least twice the size of the font size you're using.

Upvotes: 3

user529758
user529758

Reputation:

UITextFields are one-line controls. They can't display multiple lines of text. Use UITextView for that purpose.

Upvotes: 2

Related Questions