返回的类型有总是,定义的返回类型为optional (可选值)。你可以这样override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell? = self.tableView.dequeueReusableCellWithIdentifier("reuseIdentifier") as? UITableViewCell
// Configure the cell..
return cell }
var cell: UITableViewCell? = self.tableView.dequeueReusableCellWithIdentifier("reuseIdentifier") as? UITableViewCell
// Configure the cell..
return cell }
var cell: UITableViewCell? = self.tableView.dequeueReusableCellWithIdentifier("Identifier") as? UITableViewCell
return cell
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell = tableView?.dequeueReusableCellWithIdentifier("reuseIdentifier") as? UITableViewCell
return cell }
试了不行。。还是这个错误。我是直接继承UITableView的类,然后这个方法也是由系统自动生成。然后就出错了
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell = tableView?.dequeueReusableCellWithIdentifier("reuseIdentifier") as? UITableViewCell
return cell }
两个都试了。。都是不行。都是同一个错误。
/////改成
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? 再试试吧。如果还有问题。那真。。
依然是不行我觉得很奇怪就是这个类我是直接继承自UITableViewController的,这些由系统自动生成的方法都有错误我就觉得很奇怪。