KUN*_*UNG 0 uitableview ios swift indexpath
我range出错了......
发生错误cell.creditLabel.text = numOfDays[(indexPath as NSIndexPath).row] + "days".
如果我把tableView.reloadData()后cell.nameLabel.text = nameArray[(indexPath as NSIndexPath).row]
然后在模拟器中没有任何东西出现......
我该如何解决这个问题..?
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.nameArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell : MoneyTableViewCell = tableView.dequeueReusableCell(withIdentifier: "MoneyTableViewCell", for: indexPath) as! MoneyTableViewCell
cell.nameLabel.text = nameArray[(indexPath as NSIndexPath).row]
cell.creditLabel.text = numOfDays[(indexPath as NSIndexPath).row] + "days"
cell.levelLabel.text = creditArray[(indexPath as NSIndexPath).row]
cell.layoutIfNeeded()
return cell
}
Run Code Online (Sandbox Code Playgroud)
你需要检查你的阵列.从我在这里看到的,numOfDays那么有更少的元素nameArray.此外,当你在那里检查creditArray:)
此外,NSIndexPath没有必要演员.
| 归档时间: |
|
| 查看次数: |
1204 次 |
| 最近记录: |