I have a tableview where user enters his social media profile urls. I want to get the value of that textfields on click of a button. The tableview is dynamic. I have attached the screenshot for reference. I am using Objective C to build up an iOs App and I am new to it. Any suggestions on how to do that? Thanks in advance.
[![This is the tableview with textfield in cell]
I have tried this :
NSMutableArray *Array = [NSMutableArray array];
for (int i=0; i < getMYurl.count; i++){
NSIndexPath *indexPath = [NSIndexPath indexPathForRow: i inSection: 0];
SHOWURLTableViewCell *cellS = [table cellForRowAtIndexPath:indexPath];
NSMutableDictionary *Dict = [NSMutableDictionary dictionary];
UITextField *TextName= (UITextField*)[cellS.contentView viewWithTag:indexPath.row];
}
And my cellForRowAtIndexPath Method :
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cellS = (SHOWURLTableViewCell *) [tableView dequeueReusableCellWithIdentifier:@"cell"];
// cellS.labelDesc.text = mergeName;
NSString *urlText = [[getMYurl valueForKey:@"url"]objectAtIndex:indexPath.row];
cellS.labelUrl.text = urlText;
NSString *urlName = [[getMYurl valueForKey:@"url_name"]objectAtIndex:indexPath.row];
// [urlMap setValue:mergeName forKey:urlText];
cellS.urlNameET.tag = 100;
}
You should have to store text of textfiled in any array variable (index wise) after end typing. Because tableview destroy the tableview cell while that was not showing into a screen.
- (void)textFieldDidEndEditing:(UITextField *)textField{
UITableViewCell *cell = (UITableViewCell*) textField.superview.superview;
NSIndexPath *txtIndPath = [self.tblPendingDeliveryData indexPathForCell:cell];
[myMutableArray insertObject:textField.text atIndex:txtIndPath.row];
}
Don't forgot to set delegate to textfield
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.