【发布时间】:2012-02-03 05:33:20
【问题描述】:
我有一个 grouped table with 3 categories and one header above the first one 。我希望在用户输入他/她的名字后,标题标题用那个人的名字更新。在我解雇第一响应者(键盘)之后,我已将 reloadData 方法放入 textFieldShouldReturn 中。它似乎不起作用。标题标题保持不变。
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(section == 0 )
{
if(title==nil)
return @"Your name here...";
else
return title;
}
else return nil;
}
title 是一个NSString,它应该包含标题单元格中的文本。
以下代码来自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;
}
谢谢!
【问题讨论】:
-
您能否修改您的原始问题以显示
UITextField * txt = ...初始化程序的调用位置/方式?现在我怀疑你经常反复调用 alloc/init 方法,因此你的title变量总是设置为 NULL。 -
reloadData仅重新加载表格单元格或整个表格,包括页眉和页脚?
标签: ios header tableview title reload