理解titleForHeaderInSection整数返回

时间:2015-04-08 04:13:38

标签: ios uitableview swift

我的UITableView中有4个部分。我想为每个部分添加不同的标题标题。到目前为止,我有这个:

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    var title = ""

    switch section {
    case: 0
        title = "First Section"
    case: 1
        title = "Second Section"
    case: 2
        title = "Third Section"
    case: 3
        title = "Fourth Section"
    }

    return title
}

但是,每当我打印出section变量时,我都会收到0到2之间的整数变化。我的控制台打印出来

0
0
1
1
2
2
0
0
1
1
2
2
0
0
1
1
0
1
2

我在这里遗漏了什么吗?为什么section变量现在只是打印出0,1,2和3?

0 个答案:

没有答案
相关问题