2

UISlider を含む UITableViewCell があります。UISlider の値で更新したい tableview のフッター テキストがあります。

ただし、[self.tableView reloadData] を呼び出します。呼び出しが多すぎるため、UISlider では機能しません。セルを正しく更新できます (値も表示されます) が、フッター テキストを更新できません。私が試してみました:

[self tableView:self.tableView titleForFooterInSection:0];

しかし、それは動作しません..

4

1 に答える 1

4

スライダーをコントローラーのアクション メソッドに接続します。

[theSlider addTarget:self 
              action:@selector(adjustSliderValue:) 
    forControlEvents:UIControlEventValueChanged];

スライダー アクション メソッドを実装します。

- (void) adjustSliderValue: (UISlider *) slider
{
    // Change controller's state here. 
    // The next line will trigger -tableView:titleForFooterInSection:
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex: mySectionIndex] 
                  withRowAnimation:UITableViewRowAnimationNone];
}

これは、テーブル全体を再ロードするよりも効率的です。残念ながら、セクション フッター テキストを直接設定する方法はありません。

于 2010-01-19T16:01:05.410 に答える