gpt4 book ai didi

ios - TableView 错误 Swift 2

转载 作者:行者123 更新时间:2023-11-29 01:00:26 24 4
gpt4 key购买 nike

我是编码新手,所以我不确定如何修复此错误:

private let cellReuseIdentifier = "ArticleViewCell"
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

var cell = tableView.dequeueReusableCellWithIdentifier(cellReuseIdentifier) as? UITableViewCell

if cell == nil {
cell = ArticleViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: cellReuseIdentifier)
}

我收到这个错误:

Downcast from 'UITableViewCell?' to 'UITableView only warps optionals; did you mean to use "!"? 

我尝试将 ? 更改为 ! 也出现错误。

最佳答案

尝试

let cell = tableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath: indexPath) as! UITableViewCell

另外,不要忘记归还手机。

return cell

关于ios - TableView 错误 Swift 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37061422/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com