如何填充 UITableView 节标题?

Pan*_*ngu 6 xcode objective-c ios

如何向 UITableView 单元格中的节标题添加一些填充?

我有这个: 在此输入图像描述

我有一个 NSDictionary,其键值包含一串时间。我将键值存储在 NSArray 中。

我使用 titleForHeaderInSection 而不是 viewForHeaderInSection。

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{   
    return [schedule objectAtIndex:section];
}
Run Code Online (Sandbox Code Playgroud)

但是,节标题始终向左对齐。我可以使用 viewForHeaderInSection 的 UIView 将其填充到我喜欢的位置,但是有什么方法可以为方法 titleForHeaderInSection 做到这一点吗?

Pan*_*ngu 2

我无法使用 titleForHeaderInSection 轻松完成此操作,因此我决定使用带有 viewForHeaderInSection 的自定义单元格。