iOS:如何从tableview的自定义单元格中的UITextField访问值

iOS*_*oob 1 objective-c uitableview uitextfield ios

我有一个包含自定义单元格的表视图,其中包含多个文本字段.我希望在单击按钮的文本字段中输入值在cellForRowAtIndexPath中的某个位置.可能吗 ?

下面是表格视图单元格中的文本字段的屏幕截图

上图是表视图单元格中文本字段的屏幕截图.

Abh*_*rma 5

你可以得到功能的UITextField帮助Tag.

假设你有3合UITextField1 Cell.

TagUITextFieldcellForRowAtIndexPath方法如下方式.

[cell.TextField1 setTag:(1000 + indexPath.row)];
[cell.TextField2 setTag:(5000 + indexPath.row)];
[cell.TextField3 setTag:(9000 + indexPath.row)];
Run Code Online (Sandbox Code Playgroud)

为了让UITextField你可以使用以下行.

// Replace 1000 with your tag value
UITextField * textField = (UITextField *)[self.tableView viewWithTag:1000];
NSLog(@"Value of textfield = %@",[textField text]);
Run Code Online (Sandbox Code Playgroud)