yze*_*t00 15 uitableview ios swift xcode7 swift2
我在此代码中遇到以下错误:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell: UITableViewCell? = tableView.dequeueReusableCellWithIdentifier("Cell") as? UITableViewCell
错误:来自'UITableViewCell?'的沮丧?'UITableViewCell'只展开选项; 你的意思是用'!'?
有任何想法吗?
Lon*_*ham 30
在Swift2.0方法dequeueReusableCellWithIdentifier是声明为:
@available(iOS 6.0, *)
func dequeueReusableCellWithIdentifier(identifier: String, forIndexPath indexPath: NSIndexPath) -> UITableViewCell
你不应该投UITableViewCell给UITableViewCell?.见下面的代码.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)
    // Configure the cell...
    return cell
}
希望这可以帮助!