I have a grouped table with 3 categories and one header above the first one . I would like that after the user types in his/her name , the header title to update itself with that person's name . I've put the reloadData
method in textFieldShouldReturn
after I dismiss the first responder ( keyboard ) . It does not seem to work though . The header title remains the same .
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(section == 0 )
{
if(title==nil)
return @"Your name here...";
else
return title;
}
else return nil;
}
title
is a NSString
which should contain the text from the title cell.
The following code is from cellForRowAtIndexPath
....
UITextField *txt = [[ UITextField alloc ] initWithFrame:CGRectMake(100,10, 200, 30)];``
txt.delegate = self;
[cell addSubview:txt];
if(indexPath.section==0)
{
if([indexPath row] == 0)
{
[cell.textLabel setText:@"Name"];
title = txt.text;
}
Thanks!