I have a UITableViewCell which has a UISlider in it. I have a footer text for the tableview that I would like to update with the value of the UISlider.
However, calling [self.tableView reloadData]; does not wo开发者_运维百科rk for the UISlider, as it is too many calls. I am able to update the cell correctly (it also shows the value), but I am unable to update the footer text. I have tried:
[self tableView:self.tableView titleForFooterInSection:0];
But it doesn't work..
Connect your slider to an action method in your controller:
[theSlider addTarget:self
action:@selector(adjustSliderValue:)
forControlEvents:UIControlEventValueChanged];
Implement the slider action method:
- (void) adjustSliderValue: (UISlider *) slider
{
// Change controller's state here.
// The next line will trigger -tableView:titleForFooterInSection:
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex: mySectionIndex]
withRowAnimation:UITableViewRowAnimationNone];
}
This is more efficient than reloading the whole table. Unfortunately, there is no way to set a section footer text directly.
精彩评论