Create a subclass of UITableViewCell
, and use it for cells. Add a property to reference its text field:
@interface YourTableViewCell : UITableViewCell
@property (strong) UITextField *textField;
@end
Then, assign the text view to the cell when you create it:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cellIdentifier";
YourTableView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = ... // Create the cell here
UITextField *textField = ... // Create your text field here
cell.textField = textField; // Assign the text field to the cell
}
return cell;
}
Once you have done this, your text field is now linked to the cell it is in, so you can get the text view from the cell and set its value.