Form with UITableView

问题描述:

我使用UITableView创建窗体,我希望当我点击我行的任何部分时,将焦点放在文本字段上,以便我可以在上面写上。现在要专注于文本字段(黄色空间),我只能点击文本字段(参见图片)。名称是标题(不可编辑)enter image description hereForm with UITableView

非常感谢

假设您有一个名为myTextField的textField,您希望在选择表中的第一行时专注于此字段。

为此在您的didSelectRowAtIndexPath:方法

if (indexPath.row == 0) { 
    [myTextField becomeFirstResponder]; 
} 
+0

它的工作非常感谢。 – Pach 2012-08-15 15:00:25

在该行的-didSelectRowAtIndexPath,调用[correspondingTextField becomeFirstResponder];

可以使文本框为“becomefirstreponder”在案件didselectrow你在表视图拥有它。

如果您正确设置委托,则这是在用户单击任何行时触发的委托方法。 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

所以,在这种方法中,您将使用becomeFirstResponder方法来获得焦点。

[yourTextField becomeFirstResponder ];