Iam trying to retreive the textfield data from custom cell after click button which is placed in last cell of index,that means my table have a submit button to retreive the data from custom cell, for that reason i placed my button in xib and loaded after my array count, for that i written code like this
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [[dic_demo objectForKey:@"Demo"] count]+1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger lastSectionIndex = [tableView numberOfSections] - 1;
NSInteger lastRowIndex = [tableView numberOfRowsInSection:lastSectionIndex] - 1;
NSIndexPath *pathToLastRow = [NSIndexPath indexPathForRow:lastRowIndex inSection:lastSectionIndex];
if (indexPath==pathToLastRow)
{
// for submit button through xib
}
else { normal custom cell for textfields }
}
to retreive the data i written code like this
[mutarr_txt_TCelltext removeAllObjects];
for (int i =0; i<[[dic_demo objectForKey:@"Demo"] count]; i++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
CustomTableViewCell *cell = (CustomTableViewCell *)[self.tbl_SBeneficiaries cellForRowAtIndexPath:indexPath];
for(UIView *view in [cell.contentView subviews])
{
if([view isKindOfClass:[UITextField class]])
{
UITextField *textField = (UITextField *)view;
NSLog(@"%@",textField.text);
NSString *str_txt=[NSString stringWithFormat:@"%@",textField.text];
NSLog(@"First text is %lu",(unsigned long)[str_txt length]);
if ([str_txt length]>1) {
[mutarr_txt_TCelltext addObject:str_txt];
}
}
}}
but my problem is not getting first indexpath tetxtfield data & remaining textfield data is retreving. Could anyone help on this,Please find my screen shots
0 comments:
Post a Comment