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
How to Make Nsurlsession Post Request in Swift
When to Use a Colon with a @Selector
Invalid Signature (Invalid Binary) on Itunes Connect
iOS - Is Motion Activity Enabled in Settings > Privacy > Motion Activity
Uilabel with Two Different Color Text
Cabasicanimation Rotate Returns to Original Position
How to Tell What Profile/Signing Certificate Was Used to Sign .Ipa
Change Tab Bar Tint Color on iOS 7
Press-And-Hold Button for "Repeat Fire"
Highlight Just the Text in a Uilabel
Why Would a 'Scheduledtimer' Fire Properly When Setup Outside a Block, But Not Within a Block
Swift: Random Number for 64-Bit Integers
How Reliable Is Kvo with Uikit
Clang(Llvm) Compile with Frameworks