Pangu Pangu - 1 year ago 128
Objective-C Question

How to pad a UITableView section header?

How would you add some padding to a section header in a UITableView cell?

I have this:
enter image description here

I have an NSDictionary whose key values contain a string of times. I stored the key values in an NSArray.

I am using titleForHeaderInSection instead of viewForHeaderInSection.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
return [schedule objectAtIndex:section];

However, the section header is aligned all the way to the left. I can pad it to my liking using a UIView for viewForHeaderInSection, but is there any way to do it for the method titleForHeaderInSection?

Answer Source

I couldn't easily do it using the titleForHeaderInSection so I decided to use a custom cell with viewForHeaderInSection.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download