我尝试从点击按钮放置在索引的最后一个单元格后从自定义单元格中检索文本字段数据,这意味着我的表格有一个提交按钮,用于从自定义单元格中检索数据,因此我放置了我的按钮位于xib
并在我的数组计数后加载,因为我编写了这样的代码
- (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
}
}
检索我编写的代码这样的数据
[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];
}
}
}}
但我的问题是没有获得第一个indexpath tetxtfield数据&amp;剩余的文本字段数据正在退缩。任何人都可以帮忙,请找到我的屏幕截图