遍历UITableView中的所有UITextField [英] Looping through all the UITextFields in a UITableView
问题描述
我有一个UITableView
,每个单元格中都包含一个UITextField
.
我似乎无法弄清楚如何遍历并获取每个UITextFields
.
有什么办法做到吗?
I have a UITableView
that contains a UITextField
in each cell.
I can't seem to figure out how to loop through and get each of the UITextFields
.
Is there any way to do this???
非常感谢, 布雷特(Brett)
Many thanks, Brett
推荐答案
如果在创建每个文本字段时都设置了标签,则可以执行以下操作:
If you set the tag for each text field as you create it, you could do something like this:
for ( aCell in [theTable visibleCells] ) {
aField = (UITextField *)[aCell viewWithTag:kYourTextFieldTag];
}
表视图不保留可见单元格以外的单元格,并暂时保留重新排队的单元格.如果要使单元格(或仅文本字段)在滚动到表的可见区域之外时仍然存在,则必须将其保留在其他位置.
The table view does not keep cells other than the visible cells and, temporarily, requeued cells. If you want cells, or just the text fields, to persist when scrolled outside the visible area of the table you must retain them elsewhere.
这篇关于遍历UITableView中的所有UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!