/ / IOS - Styling Headers Section in a static UITableViewController - IOS7 - ios, Objective-C, Uitableview

IOS - Styling Section Headers v statickej UITableViewController - IOS7 - ios, objektív-c, uitableview

Je možné upraviť hlavičku sekcieštýl pozadia / písma v statickom UITableViewController? Nevidím žiadnu možnosť scenára, ako to urobiť, a keďže je tabuľka statická, metódy tabuľky boli v súbore.M deaktivované - takže si nie som istý, ako programovo použiť styling?

odpovede:

6 pre odpoveď č. 1

Protokol UITableViewDelegate definuje metódu viewForHeaderInSection, ktorú je možné vo vašom delegátovi implementovať na vrátenie vlastných zobrazení hlavičky (funguje aj pre statické UITableViews). napr .:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
// you can get the title you statically defined in the storyboard
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];

// create and return a custom view
UILabel *customLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 50.0f)];
customLabel.text = sectionTitle;
return customLabel;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
// return a custom height here if necessary
return 50.0f;
}