我正在尝试创建一个带有两个标题(帐户、支持)和部分文本标题的 TableView。但我遇到了错误
我遵循了这个问题的答案:如何使用 swift 使用两个不同的数组填充 tableview 中的两个部分?
这是我的代码:
var myTitles = [["Delete current photo","Change profile picture","Change username","Change password"],["Help","Report a problem"]]
let headerTitles = ["Acount", "Support"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return myTitles[section].count
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 3 //This is not complete yet.
}
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section < headerTitles.count {
return headerTitles[section]
}
return nil
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("settingCell", forIndexPath: indexPath)
cell.textLabel?.text = myTitles[indexPath.section][indexPath.row]
return cell
}