【问题标题】:New line textfield- iPhone [duplicate]新行文本字段- iPhone [重复]
【发布时间】:2013-07-31 21:42:10
【问题描述】:

是否可以在textfield 占位符中添加新行?类似:

comment1= [[[UITextField alloc]initWithFrame:frame2]autorelease];
comment1.placeholder = @"Write maximum 200 \r characters here";

【问题讨论】:

  • 你能用 UITextView 代替吗?它们专为使用多条线路而设计。
  • 除非你做一些毫无意义的疯狂事情,否则 NO。你只是在浪费你的时间,你不妨使用UITextView

标签: iphone objective-c uitextfield


【解决方案1】:

UITextField 没有任何属性或工具可以在其中创建新行。您可以改用 UITextView 。这是代码示例..

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

【讨论】:

    【解决方案2】:

    UITextField 仅显示单行。如果你想显示多行文本,你必须使用UITextView。或者,您可以使用UILabel 并设置行数属性。在 iPhone 中,“\n”是换行符。但是,它不适用于UITextField

    【讨论】:

      【解决方案3】:

      UITextView 用于多行文本

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-22
        • 2015-05-17
        • 1970-01-01
        相关资源
        最近更新 更多