swift - 在 Swift 3 中使用 UITableView 和 IndexPath 显示错误

标签 swift uitableview

我有这个代码:

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: IndexPath) as? Cell

但是 IndexPath 显示错误:

enter image description here

最佳答案

let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: IndexPath) as? Cell

在这一行中,您将传递 IndexPath 类而不是函数中的 indexPath 参数。将其替换为:

let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Cell

关于swift - 在 Swift 3 中使用 UITableView 和 IndexPath 显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39500795/

相关文章:

ios - 测试与非测试中的 Swift 和 CoreData 转换问题

ios - 如何在 Swift 中设置 UIWebView 的 "User-Agent" header

ios - 使用 UITableViewCell 绘制条形图 - 单元格可变地部分填充颜色

ios - 表格 View 中的表格 View swift

uitableview - 当需要下载大量图像时如何处理内存?

ios - Swift Firebase 在 child 身上获得值(value)

ios - 圆形动画滞后

ios - UITableViewCell 保持高亮是否违反 HIGH?

ios - 选择 UITableView 时使内容可见

ios - 如何对 DatePicker 进行验证?