【发布时间】:2016-09-06 15:55:43
【问题描述】:
错误是错别字,请删除
我只是 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
}
}
【问题讨论】:
-
错字:
UITableviewCell!=UITableViewCell -
那么错误是什么?
-
你的手机注册了吗?
-
任何一个错字,但我不这么认为,因为那样会产生编译错误。我猜 cellIdentifier 在情节提要上没有正确设置。请在您的故事板中检查 uitableviewcell 的标识符
-
@MihribanMinaz 有一个编译错误,它在问题的标题中:“使用未声明的类型'UITableviewcell'”。您可以在 OP 的代码中看到确实是错字。
标签: ios xcode swift uitableview types