How to set the UITableView Section title programmatically (iPhone/iPad)?

前端 未结 8 2117
太阳男子
太阳男子 2020-12-07 10:54

I\'ve created a UITableView in Interface Builder using storyboards. The UITableView is setup with static cells and a numb

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 11:33

    If you are writing code in Swift it would look as an example like this

    func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String?
    {
        switch section
        {
            case 0:
                return "Apple Devices"
            case 1:
                return "Samsung Devices"
            default:
                return "Other Devices"
        }
    }
    

提交回复
热议问题