2
我想在UITableViewCell(每行中的一個文本字段)中添加12個UITextFields,並使用它的標記訪問每個UITextField的文本。我怎樣才能做到這一點?如何在表視圖單元格中添加12個文本字段並通過其標記值訪問每個文本字段的文本?
我想在UITableViewCell(每行中的一個文本字段)中添加12個UITextFields,並使用它的標記訪問每個UITextField的文本。我怎樣才能做到這一點?如何在表視圖單元格中添加12個文本字段並通過其標記值訪問每個文本字段的文本?
UITextField *textField = (UITextField *)[cell viewWithTag:1];
// 1 is your tag, and use textField.text to get the text in the textField.
您的代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//...
nameLabel.tag =1; // 1 is your nameLabel's tag
[tv setDelegate:self];
tv.tag = indexPath.row + 1; // set it to tv.tag = indexPath.row + 2; because 1 is your nameLabel's tag
UITextField *textField = (UITextField *)[cell viewWithTag:tv.tag];//
NSLog(@"%@",textField.text);
return cell;
http://stackoverflow.com/questions/19621732/how-to-add-textfield-in-tableview-cell-and-access-each-textfields-文本按他們的 – Siva