2011-07-11 43 views
-1

我有屏幕底部的一个listview和屏幕顶部的一个4字段输入窗体。当我点击列表项目时,我想将焦点设置到第1个文本字段。UITextField becomeFirstResponder不起作用

我有这样的代码:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    .... 
    .... 
    else if(editingStyle == UITableViewCellEditingStyleInsert) 
     { 
       [self clrscreen]; 

       [oDescription becomeFirstResponder]; 
      } 

,但它不工作。我一定要得到的焦点从列表视图第一或东西

回答

1

的也许在处理该UI的

[self clrscreen]; 

方法和UITableView的重绘。如果是这样,那么你现在称之为

[oDescription becomeFirstResponder]; 

它不在那里。请检查oDescription是不是nil

一两件事:在那里/时,这家名为:

.... 
.... 
else if(editingStyle == UITableViewCellEditingStyleInsert) ? 
+0

的clrscreen一定是这个问题,我删除了它,现在一切都很好。我还添加了我在上面的方法的标题。感谢您的帮助! –

+1

很高兴为您效劳。也许投票的帖子?:) – Daniel

相关问题