sample.h
@interface sample : UIViewController
{
}
@end
sample.m
-(void)viewWillAppear:(BOOL)animated
{
arrData = [[NSMutableArray alloc]init];
for (int i=0; i<10; i++) // 10- number of fields
[arrData addObject:@""];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [arrData count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UITextField *txt = [[UITextField alloc]initWithFrame:frm];
txt.autocorrectionType = UITextAutocorrectionTypeNo;
txt.tag = indexPath.row;
txt.delegate = self;
txt.text = [arrData objectAtIndex:indexPath.row];
[cell addSubview:txt];
[txt release];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[arrData replaceObjectAtIndex:[textField tag] withObject:textField.text];
}