开发者

How do I get the text from a custom UITextViewCell?

开发者 https://www.devze.com 2023-03-27 23:18 出处:网络
I\'m using a custom UITableViewCell that contains a UITextField. I draw this UITableViewCell in a UITableView 5 times with this code:

I'm using a custom UITableViewCell that contains a UITextField. I draw this UITableViewCell in a UITableView 5 times with this code:

InputCellTableViewCell *cell = [tableViewIn dequeueReusableCellWithIdentifier:@"inputCell"];

[cell setUp]; //Just sets first responder and delegate.

[cell.textField setPlaceholder:[self.arrayWithFields objectAtIndex:indexPath.row]];
return cell;

When the user have inputed data into the five cells, how do I access each of the cells data o the best way an开发者_开发问答d save it? I do not have a decleration for each cell as you can see.


You can use the tag for your UITextField for each cell

   if (indexPath.section == 0) {

        // Add a UITextField
        UITextField *textField = [[UITextField alloc] init];
        // Set a unique tag on each text field
        textField.tag = indexPath.row;
        [cell.contentView addSubview:textField];
        [textField release];
    }
    if (indexPath.section == 1) {

        // Add a UITextField
        UITextField *textField = [[UITextField alloc] init];
        // Set a unique tag on each text field
        textField.tag = indexPath.row;
        [cell.contentView addSubview:textField];
        [textField release];
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消