Changing Uitableview's Section Header/Footer Title Without Reloading the Whole Table View

Changing UITableView's section header/footer title without reloading the whole table view

I managed to do it in an indirect way: I created a UILabel and set it as section header/footer.

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
// update sectionFooterView.text
return sectionFooterView;
}

- (void)viewDidLoad {
// create sectionFooterView in Interface Builder, change the frame here
// use Font-size:15 , BG-Color: clearColor , text-Color: RGB=(97,105,118)
// and Text-alignment:Center to look like table view's original footer
sectionFooterView.frame = CGRectMake(0, 10, 320, 12);
}

Does anyone know a way to do this without setting a custom footer view?

Update section footer title in UITableView without reloading

If you have groupped table, you can use:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
yourLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 17)]; //I'm not sure about the frame...
yourLabel.font = [UIFont systemFontOfSize:16];
yourLabel.shadowColor = [UIColor whiteColor];
yourLabel.shadowOffset = CGSizeMake(0, 1);
yourLabel.textAlignment = UITextAlignmentCenter;
yourLabel.textColor = RGB(76, 86, 108);
yourLabel.backgroundColor = [UIColor clearColor];
yourLabel.opaque = NO;
return yourLabel;
}

Declare yourLabel in your .h file. Then, you can access it via

yourLabel.text = @"whatever you want";

Please check if that works :)

How to update a custom section header without reloading the whole table view?

try reloadSections method :

In Swift

let sectionToReload = 1
let indexSet: IndexSet = [sectionToReload]

self.tableView.reloadSections(indexSet, with: .automatic)

In Objective c

- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation

Reload tableView section without reloading header section - Swift

You could use UITableView's reloadSections method instead.

tableView.reloadSections(IndexSet(integer: 2), with: .none)

How to remove section header and footer view from table view?

you can edit size of sections header and footer in IB. Open Inspector on your table view and go to the size tab. Set there section header/footer height to minimum



Related Topics



Leave a reply



Submit