-2

Is it possible to put a new line in a textfield placeholder? something like:

comment1= [[[UITextField alloc]initWithFrame:frame2]autorelease];
comment1.placeholder = @"Write maximum 200 \r characters here";
Girish
  • 4,692
  • 4
  • 35
  • 55
Andrea F
  • 733
  • 2
  • 9
  • 16
  • Can you use a UITextView instead? They are designed for using multiple lines. – Fogmeister Jul 31 '13 at 11:32
  • Unless you do some pointless crazy stuff then **NO**. You would just be wasting your time you might as well use `UITextView`. – Popeye Jul 31 '13 at 12:55

3 Answers3

4

UITextField is meant to show only single line. If you wish to show multiple line text you'll have to use UITextView. Or, you can use UILabel and set the number of lines property. In iPhone "\n" is new line character. However, it won't work with UITextField.

Rushi
  • 4,553
  • 4
  • 33
  • 46
2

Use UITextView for multiline text

Sahil Mahajan
  • 3,922
  • 2
  • 29
  • 43
-1

UITextField does not have any property or facility to create new line in it. You can use UITextView instead. Here is the code sample..

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if([text isEqualToString:@"\n"])
{ //Enter your code here }}
A K
  • 149
  • 1
  • 11