ingenspor
ingenspor

Reputation: 932

Edit custom UITableViewCell textView when didSelectRowAtIndexPath

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

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

Is there a way to do this? How?

Upvotes: 0

Views: 216

Answers (2)

prasad
prasad

Reputation: 2026

If you have added textview as a subview to cells contenview then you can try this

  • (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];
    }
}

}

Upvotes: 1

0xDE4E15B
0xDE4E15B

Reputation: 1294

For example, you have a custom UITableViewCell with the

@property (nonatomic, retain) UITextView* textView;

so, to appear the keyboard

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

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

Upvotes: 2

Related Questions