Uitableview 选择UITextView行时,如何使UITextField进入编辑模式
我的一个UITableView行中有一个UITextField子视图。当我点击一行(在UITextField框架之外)时,我希望UITextField变得可编辑(即显示数字键盘),就像我在UITextField框架内点击一样 我见过一些类似的问题,建议使用becomeFirstResponder,但这对我不起作用 我该怎么做?我是否应该以某种方式将UITextField帧之外的触摸事件转发到UITextFieldUitableview 选择UITextView行时,如何使UITextField进入编辑模式,uitableview,uitextfield,Uitableview,Uitextfield,我的一个UITableView行中有一个UITextField子视图。当我点击一行(在UITextField框架之外)时,我希望UITextField变得可编辑(即显示数字键盘),就像我在UITextField框架内点击一样 我见过一些类似的问题,建议使用becomeFirstResponder,但这对我不起作用 我该怎么做?我是否应该以某种方式将UITextField帧之外的触摸事件转发到UITextField - (void)tableView:(UITableView *)tableVie
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self selectSection: indexPath.section];
switch( indexPath.section )
{
case SECTION_RATE:
currentTextField = editRate;
[editRate becomeFirstResponder];
break;
case SECTION_UNITS:
currentTextField = editUnits;
[editUnits becomeFirstResponder];
break;
default:
break;
}
}
在didSelectRowAtIndexPath中,检查索引路径并
tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
if(indexpath.row == 0)
{
[txtField1 becomeFirstResponder];
//adjust table scroll for keyboard
}
else if(indexpath.row == 1)
{
[txtField2 becomeFirstResponder];
//adjust table scroll for keyboard
}
在didSelectRowAtIndexPath中,检查索引路径并
tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
if(indexpath.row == 0)
{
[txtField1 becomeFirstResponder];
//adjust table scroll for keyboard
}
else if(indexpath.row == 1)
{
[txtField2 becomeFirstResponder];
//adjust table scroll for keyboard
}
谢谢我已经编辑了我上面的帖子-我正在做一些类似于你所建议的事情。刚刚注释掉selectSection方法调用,它就可以工作了。。因此,我的selectSection方法中肯定有一个bug(这实际上只是为了跟踪所选内容并忽略可能显示的UIPickerView)。我会接受你的回答,因为你已经确认我做的事情是“正确的”。。我只需要找到我的虫子。:)谢谢我已经编辑了我上面的帖子-我正在做一些类似于你所建议的事情。刚刚注释掉selectSection方法调用,它就可以工作了。。因此,我的selectSection方法中肯定有一个bug(这实际上只是为了跟踪所选内容并忽略可能显示的UIPickerView)。我会接受你的回答,因为你已经确认我做的事情是“正确的”。。我只需要找到我的虫子。:)