UITextfield不可编辑-iPhone [英] UITextfield not editable-iphone

查看:46
本文介绍了UITextfield不可编辑-iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经以编程方式创建了文本字段,单击该文本字段将无法对其进行编辑.我究竟做错了什么?

I have programatically created textfields that will not become editable when clicked. What am I doing wrong?

CGRect frame3 = CGRectMake(100, 730, 100, 30);
UITextField *textfield3 = [[UITextField alloc] initWithFrame:frame3];
textfield3.borderStyle = UITextBorderStyleRoundedRect;
textfield3.textColor = [UIColor blackColor];
[self.view endEditing:YES];
[self.view addSubview:textfield3];

推荐答案

摆脱这一点,开始于:

[self.view endEditing:YES];

如果要调出新添加的文本字段的键盘,请在将其作为子视图添加到父视图后立即执行以下操作:

If you want to bring up the keyboard for the newly added text field, do this right after adding it as a subview to your parent view:

[textfield3 becomeFirstResponder];

这篇关于UITextfield不可编辑-iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆