didSelectRowAtIndexPath时编辑自定义UITableViewCell textView

时间:2012-08-30 17:07:40

标签: objective-c xcode

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

if(indexPath.row==0) {
//Edit the textView in this cell   
}

有办法做到这一点吗?怎么样?

2 个答案:

答案 0 :(得分:2)

例如,您有一个带有

的自定义UITableViewCell
@property (nonatomic, retain) UITextView* textView;

所以,出现键盘

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

       if(indexPath.row==0) {
          [tableView cellForRowAtIndexPath:indexPath]textView]becomeFirstResponder];
       }
    }

答案 1 :(得分:1)

如果您已将textview作为子视图添加到单元格contenview,那么您可以尝试此

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

 for(int i=0;i<[[cell.contentView subviews] count];i++)
  {

    if([[[cell.contentView subviews] objectAtIndex:i] isKindOfClass:[UITextView class]])
    {
        [[[cell.contentView subviews] objectAtIndex:i] becomeFirstResponder];
    }
}

}