0
私は2つのヘッダとテーブルビューを作成しようとしています(アカウント、サポート) とsections.But内のテキストのタイトルは、私がエラーに '[<String>]'型の値に '(section)'型のインデックスを付けることはできません。タイプ」(別名 『section.Type』)
を取得していますし、私はこの質問から答えを追いました: How do I populate two sections in a tableview with two different arrays using swift?これは私のコードです:
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
}
あなたがここに
section
値を取得しているすべての