4

I'm trying to add lines to my UITextField (my code is below), however, when the typer gets to the end of the text field, instead of going to the next line it keeps going on the same line forever! How do I get it to go to the next line? Thanks.

fldNotes = [[UITextField alloc] initWithFrame:CGRectMake(labelLeft,controlTop+5,320 - (2 * labelLeft),200)];
fldNotes.text = te.notes;
fldNotes.placeholder = [theApp.adb GetHC:@"NotesName"];
fldNotes.clearButtonMode = UITextFieldViewModeWhileEditing;
fldNotes.tag = 100;
fldNotes.borderStyle = UITextBorderStyleRoundedRect;
[fldNotes setReturnKeyType:UIReturnKeyDone];
[fldNotes setEnablesReturnKeyAutomatically:YES];
fldNotes.delegate = self;

[contentView addSubview:fldNotes];
Jack
  • 361
  • 1
  • 4
  • 6

2 Answers2

1

You can also customize your UITextView to look alike UITextField by using this.

 myTextView.layer.cornerRadius = 5;
    [myTextView.layer setBorderColor:[[[UIColor grayColor] colorWithAlphaComponent:0.5] CGColor]];
    [myTextView.layer setBorderWidth:2.0];    
    myTextView.clipsToBounds = YES;

Dont forget to import <QuartzCore/QuartzCore.h> and you wil get rid of the error.

Hope this helps Someone:)

Dalee Davis
  • 981
  • 8
  • 19
1

use a UITextView instead. This allows for multi-line text.

Chris Kooken
  • 32,730
  • 15
  • 85
  • 123
  • Bear in mind that UITextView does not have all the features of UITextField, such as placeholder text, and that dismissing the keyboard with the return key is difficult/bad practice, for example. – HenryRootTwo Apr 07 '14 at 23:24