【发布时间】:2016-10-04 16:35:09
【问题描述】:
我想弄清楚如何为我的 swift 项目添加一个简单的标题。我已经在表格视图中列出了学生,只想在列表上方的中心添加一个标题,上面写着“学生”,但我一生都想不通。每次我尝试添加任何内容时,它要么妨碍运营商设置,要么不出现。他是我所有的代码,除了一个尝试的标题栏。
class StudentRosterTableViewController: UITableViewController {
var studentsList = [Dictionary<String, String>]()
override func viewDidLoad() {
super.viewDidLoad()
let studentRoster = ClassRosterModel()
studentsList = studentRoster.studentRoster
}
// MARK: - Table view data source
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return studentsList.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("StudentCell", forIndexPath: indexPath)
// Configure the cell...
cell.textLabel!.text = studentsList[indexPath.row]["name"]
cell.detailTextLabel!.text = studentsList[indexPath.row]["number"]
return cell
}
【问题讨论】:
标签: ios swift uitableview titlebar