UITextField-多行

UITextField-多行,text,uitextfield,field,lines,cgrect,Text,Uitextfield,Field,Lines,Cgrect,我试图在UITextField中添加行(我的代码在下面),但是,当打字机到达文本字段的末尾时,它将永远保持在同一行,而不是下一行!我如何让它转到下一行?谢谢 fldNotes = [[UITextField alloc] initWithFrame:CGRectMake(labelLeft,controlTop+5,320 - (2 * labelLeft),200)]; fldNotes.text = te.notes; fldNotes.placeholder = [theApp.adb G

我试图在UITextField中添加行(我的代码在下面),但是,当打字机到达文本字段的末尾时,它将永远保持在同一行,而不是下一行!我如何让它转到下一行?谢谢

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];

改用
UITextView
。这允许多行文本。

您也可以使用此选项自定义UITextView,使其看起来像UITextField

 myTextView.layer.cornerRadius = 5;
    [myTextView.layer setBorderColor:[[[UIColor grayColor] colorWithAlphaComponent:0.5] CGColor]];
    [myTextView.layer setBorderWidth:2.0];    
    myTextView.clipsToBounds = YES;
别忘了导入,这样你就会消除错误


希望这对某人有所帮助:)

请记住,UITextView没有UITextField的所有功能,例如占位符文本,并且使用返回键关闭键盘是一种困难/糟糕的做法。您尝试模拟的样式是否会随IOS版本的不同而不同?