ios - 类型 'FormBaseCell' 的值没有成员

标签 ios xcode swift

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

错误:

Value of type 'FormBaseCell' has no member.

我的代码:

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()
    }

最佳答案

我不确定您从哪里获得此代码。我从未见过有人经历所有这些步骤来获得细胞。您应该能够执行此操作:

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
}

关于ios - 类型 'FormBaseCell' 的值没有成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35993966/

相关文章:

ios - 如何在 UITableView 上设置 VoiceOver 初始焦点

IOS:带有 Storyboard的 iPad 项目中的 View 大小

ios - UITableViewCell 配件选择

ios - iOS 上的 AWSDynamoDBObjectMapper 将 Bool 值设置为 1 而不是 true?

ios - 用户在 UIImageView 中绘制内容后,如何将绘图保存在 tableview 中?

ios - UITextField 属性 KeyboardType 未按预期显示

ios - 更改 UINavigationBar 色调颜色

xcode - SplitViewController设置为窗口内容导致Window不出现

swift - 当用户点击 View Controller 中的多个 UIImage 之一时,如何打印 "image x tapped"? ( swift 3)

ios - 使用多个过滤器搜索 TableView