1

我以编程方式创建了单击时无法编辑的文本字段。我究竟做错了什么?

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

1 回答 1

0

摆脱这个,开始:

[self.view endEditing:YES];

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

[textfield3 becomeFirstResponder];
于 2013-07-04T21:56:44.173 回答