After googling this issue i managed to do this
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"InsertMarksCell";
SaveAllExamMarksForAllStudentsTableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
StudentPersonalInfo *newStudentName = feedItemsNow[indexPath.row];
myCell.txtStudentMark.text = @"hello";
myCell.txtStudentMark.delegate = self;
myCell.txtStudentMark.tag = indexPath.row;
return myCell;
}
this code i this sets the textfield " txtStudentMark " delegate and sets it's tag ...
-(void) textFieldDidEndEditing: (UITextField * ) textField
{
NSString *text = [(UITextField *)[self.view viewWithTag:55] text];
NSLog(@"%@",text);
}
i keep getting null value using the NSLog Function
i have a textField in a custom cell which the user will fill with data and i need to get all data from all textfields, am i going the right way ?
from what i understood, i need to set the tag for textField and set it as delegate, then i can call textfield by tag to get the text in it .
how can i make this work ?
Why don't you use
-(void) textFieldDidEndEditing: (UITextField * ) textField
{
NSString *text = [textField text];
NSLog(@"%@",text);
}
?
Your problem is that you are adding textfield into cell, but ask view for this tag.
EDIT:
to get your textfield from tableview
-(void) textFieldDidEndEditing: (UITextField * ) textField
{
UITableViewCell *cell = [self.view.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:55 inSection:0]];
NSString *text = [(UITextField *)[cell.contentView viewWithTag:55] text];
NSLog(@"%@",text);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments