UITableViewでインデックスの範囲外の問題が発生しています。配列の配列致命的なエラー:範囲外のインデックスのスウィフト
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 50
}
//== Teble: number of tables ==============================//
func numberOfSections(in tableView: UITableView) -> Int {
return headerTitleArray.count
}
//== Teble rows: number of rows ==============================//
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cellTitleMultiArray.count
}
//== Teble rows: data for each row ==============================//
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath) as! CustomTableViewCell
let text = cellTitleMultiArray[indexPath.section][indexPath.row]
cell.titleLabel.text = text
return cell
}
}
私はこの問題を解決しようとしていますが、私はこの問題を解決してくださいしなさいことができませんでした....それはあなたのcellTitleMultiArray
のように見える
これは正しい 'return cellTitleMultiArray.count'ですか?あなたは欲しいもののように聞こえる。私はそれが 'return cellTitleMultiArray [section] .count'であるべきだと思います –
return cellTitleMultiArray.count' =>' return cellTitleMultiArray [indexPath.section] .count' – Larme
cellTitleMultiArray [section] .countも試しましたが、クラッシュしました –