I’ve created a table where each cell holds both a text label and a text field. I’m adding the textfields as such [cell addSubview:passwordField]; and from a visual perspective they appear and are editable, etc….
The problem arises when I attempt to retrieve the entered values from the textfields. I iterate over the cells and try to grab the subview (IE the textfield), however, my iteration only discovers the text label.
Here is the code I’m using to search:
for(NSInteger i =0; i < [tableView numberOfRowsInSection:0]; i++){
NSIndexPath *path = [NSIndexPath indexPathForRow:i inSection:0];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:path];
UIView* subView = [[cell.contentView subviews]lastObject]; // I've also tried object at index here
// Anything beyond this is just matching....
Another approach I took was recursively searching the subviews, but, again that yielded no results.
You have added your
textFieldon subView of cell.While you’re trying to find it on
cell.contentView.Add your
textFieldas a subView ofcell.ContentviewAnd find it in this way –