UITextField - 多行
我正在尝试向 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];
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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
UITextView
代替。这允许多行文本。use a
UITextView
instead. This allows for multi-line text.您还可以使用此自定义 UITextView 使其看起来与 UITextField 相似。
不要忘记
导入
,这样你就会消除错误。希望这对某人有帮助:)
You can also customize your UITextView to look alike UITextField by using this.
Dont forget to
import <QuartzCore/QuartzCore.h>
and you wil get rid of the error.Hope this helps Someone:)