返回的类型有总是,定义的返回类型为optional (可选值)。你可以这样override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
        var cell: UITableViewCell? = self.tableView.dequeueReusableCellWithIdentifier("reuseIdentifier") as? UITableViewCell
        // Configure the cell..
        return cell    }

解决方案 »

  1.   

    楼主,你好。参数或者返回类型报错误了。建议你采用这种方法: override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
            var cell: UITableViewCell? = self.tableView.dequeueReusableCellWithIdentifier("Identifier") as? UITableViewCell
            return cell
     
        }   
      

  2.   

    如果上面的不行,改这个试试
    override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
            var cell = tableView?.dequeueReusableCellWithIdentifier("reuseIdentifier") as? UITableViewCell
            return cell    }
      

  3.   


    试了不行。。还是这个错误。我是直接继承UITableView的类,然后这个方法也是由系统自动生成。然后就出错了
      

  4.   

    如果上面的不行,改这个试试
    override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
            var cell = tableView?.dequeueReusableCellWithIdentifier("reuseIdentifier") as? UITableViewCell
            return cell    }
    两个都试了。。都是不行。都是同一个错误。
      

  5.   

    你重写的这个函数中tableview使用的是optional 可选值,应该是使用(?),而你这里断定tableview不为空,使用的(!),你改一下你的函数override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! 
    /////改成
    override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? 再试试吧。如果还有问题。那真。。
      

  6.   


    依然是不行我觉得很奇怪就是这个类我是直接继承自UITableViewController的,这些由系统自动生成的方法都有错误我就觉得很奇怪。