如何在UITableViews中编辑多个部分标题?

时间:2015-06-25 17:13:44

标签: ios uitableview

我的UITableView包含多个sections,我希望这些sections具有不同的名称。提供了titleForHeaderInSection方法来更改section的名称。它返回String,看起来像这样:

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    return "My First Section"
}

这非常适合更改一个名称,但如果我有多个sections怎么办?我应该使用多个功能吗?我应该在viewDidLoadnumberOfSectionsInTableView方法中以某种方式声明名称吗?但他们并不喜欢正确的选择。

如何在sections编辑UITableViews的多个标题?

1 个答案:

答案 0 :(得分:1)

使用section标题数组,返回正确的字符串,如下所示:

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    let sectionInfo = arrayOfSectionNames[section]
    return sectionInfo 
}
相关问题