【问题标题】:Creating a UITextField that creates a new line when needed创建一个 UITextField,在需要时创建一个新行
【发布时间】:2014-02-01 23:16:48
【问题描述】:

我想知道如何创建一个 UITextField,当文本到达它的边缘时会创建一个新行。

我是如何创建文本视图的:

UITextField *textField = [[UITextField alloc] init];
textField.frame = CGRectMake(0, 194, 320, 568);
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
textField.backgroundColor = [UIColor whiteColor];
UIView *textPaddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 7, 20)];
textField.leftView = textPaddingView;
textField.leftViewMode = UITextFieldViewModeAlways;
[self.view addSubview:textField];

【问题讨论】:

    标签: ios text uitextfield


    【解决方案1】:

    不,你不应该那样做。 UITextField 仅设计为只有一行文本。您应该使用的控件是UITextView,它支持您本机描述的行为。

    【讨论】:

    • 有了UITextView,用户可以写文字吗@jafar
    • @matthew 用户可以在文本视图中输入任何文本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-25
    • 1970-01-01
    • 1970-01-01
    • 2012-08-23
    • 1970-01-01
    • 2011-02-06
    • 1970-01-01
    相关资源
    最近更新 更多