【问题标题】:Value of type 'FormBaseCell' has no member“FormBaseCell”类型的值没有成员
【发布时间】:2023-04-07 02:17:01
【问题描述】:

我是 xcode 编程的新手,遇到了这个错误。我不确定新更新的 xcode 想让我在这里做什么,因为它在我升级之前就可以工作。

错误:

“FormBaseCell”类型的值没有成员。

我的代码:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let rowDescriptor = formRowDescriptorAtIndexPath(indexPath)

    let formBaseCellClass = formBaseCellClassFromRowDescriptor(rowDescriptor)

    let reuseIdentifier = NSStringFromClass(formBaseCellClass)

    var cell: FormBaseCell? = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) as? FormBaseCell
    if cell == nil {

        cell = formBaseCellClass.init(style: .Default, reuseIdentifier: reuseIdentifier)

        cell?.tableViewController = self // <--error 
        cell?.configure()
    }

【问题讨论】:

    标签: ios xcode swift


    【解决方案1】:

    我不确定您从哪里获得此代码。我从未见过有人通过所有这些步骤来获得一个细胞。你应该能够做到这一点:

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        // Set up your table and prototype cell on storyboard
        let reuseIdentifier = "MyCell"
    
        var cell: FormBaseCell? = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) as? FormBaseCell
        if let cell = cell {
            cell.textLabel.text = "something"
        }
        else {
            cell = FormBaseCell()
        }
        return cell
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-11
      • 1970-01-01
      • 1970-01-01
      • 2021-06-17
      • 2018-01-15
      • 2017-04-28
      • 2016-12-03
      相关资源
      最近更新 更多