나는 grouped table with 3 categories and one header above the first one이 있습니다. 나는 사용자가 그/그녀의 이름을 입력 한 후에 그 사람의 이름으로 자신을 업데이트하는 헤더 제목을 원한다. 첫 번째 응답자 (키보드)를 닫은 후에 reloadData
메서드를 textFieldShouldReturn
에 넣었습니다. 그래도 작동하지 않는 것 같습니다. 머리글 제목은 동일하게 유지됩니다.iOS 새로 고침 헤더 제목
-(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'는 머리말과 꼬리말을 포함하여 테이블 셀이나 전체 테이블 만 다시로드합니까? – Teo