。次に、新しい値を取得したら(そのメソッドで使用するソースを入力したら)、単に[myTableView reloadData]
を呼び出します。
だから、ヘッダタイトルをHeaderTitles
という配列に格納しているとします。あなたは確かに2つのセクションを持っているので、あなたではなく、NSArrayのを使用したくない場合、
// This is a method I made up, which is where you get the data returned...
- (void)gotNewTitle:(NSString *)title forSection:(NSUInteger)section {
[[self HeaderTitles] replaceObjectAtIndex:section withObject:title];
[[self myTableView] reloadData];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [[self HeaderTitles] objectAtIndex:section];
}
を(これは、すでにあなたのセクションヘッダのタイトルが移入されたNSMutableArrayの/ NSArrayのを持っていると仮定し)
- (void)gotNewTitle:(NSString *)title forSection:(NSUInteger)section {
switch (section) {
case 0:
[self setFirstSectionTitle:title];
break;
case 1:
[self setSecondSectionTitle:title];
break;
default:
break;
}
[[self myTableView] reloadData];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
switch (section) {
case 0:
return [self FirstSectionTitle];
break;
case 1:
return [self SecondSectionTitle];
break;
default:
return @"";
break;
}
}
:あなたは(2つの特性を前提とし、両方の
NSString
、
FirstSectionTitle
と
SecondSectionTitle
)は、以下の方法を使用することができます