Xcode 7 - Swift - 使用未声明的类型' UITableviewcell'

时间:2016-05-11 10:08:02

标签: ios xcode swift uitableview types

错误是一个类型,请删除

我刚刚接触到swift,这可能只是一个非常基本的问题。 如果有人能提供帮助那就太棒了。

我正在关注如何在swift / xcode中制作幻灯片菜单的youtube教程,并且出现了这个错误。我已经仔细检查过了,我编写了与教程完全相同的代码。我已经研究并试图解决它,但不能。

我知道错误是:

as UITableViewCell

在第5行最后一行代码。但我不知道为什么,教程说要包含它。请帮助。

import Foundation
import UIKit

class backTableViewController: UITableViewController {

  var TableArray = [String]()

  override func viewDidLoad() {
    TableArray = ["Hello", "Second", "World"]
  }

  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return TableArray.count
  }

  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableviewCell

    return cell
  }
}

1 个答案:

答案 0 :(得分:0)

在您的代码段中,您有一个拼写错误。

这一行

var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableviewCell

应该是

var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell

使用大写字母V进行UITableViewCellas UITableViewCell

希望这就是造成问题的原因