类似的问题被问到 
 here,但这并不能解决这个问题.我在ViewController中添加了一个tableView.使用它的dataSource和Delegate扩展了类,并为它添加了所需的方法.然后我在此表中创建了一个原型单元格(不是单独的.xib),并为该TableViewCell创建了一个类并收集了@IBOutlet: 
  
  
 
@IBOutlet weak var titleOfAccount: UILabel!
    @IBOutlet weak var lastModified: UILabel!
    @IBOutlet weak var accountimage: UIImageView!
    @IBOutlet weak var cellView: UIView! 
 然后在我写的表视图的cellForRowAt方法中
cell.titleOfAccount.text = "Hello World" cell.lastModified.text = "Last Modified: 21 May 2017"
并运行它与此错误崩溃的代码.
Fatal error: unexpectedly found nil while unwrapping an Optional value
我在这里和那里搜索后做了什么,我回到tableViewCell类并改变了!至 ?并将cellForRowAt中的代码更新为:
cell.titleOfAccount?.text = "Hello World" cell.lastModified?.text = "Last Modified: 21 May 2017"
现在,当我运行程序时,它运行成功,但tableView中没有出现单元格,我也实现了该方法:
func tableView(_ tableView: UITableView,numberOfRowsInSection section: Int) -> Int {
        return 3;
    } 
 这是我的cellForRowAt方法的完整代码:
func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell: AccountsTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) as! AccountsTableViewCell
        cell.backgroundColor = UIColor.clear
        cell.clipsToBounds = true
        cell.cellView.layer.shadowColor = UIColor.black.cgColor
        cell.cellView.layer.shadowOpacity = 1
        cell.cellView.layer.shadowOffset = CGSize.zero
        cell.cellView.layer.shadowRadius = 10
        cell.titleOfAccount.text = "Hello World"
        cell.lastModified.text = "Last Modified: 21 May 2017"
        cell.accountimage.image = UIImage(named: "fb")
        return cell
    } 
 附:我还在viewDidLoad中添加了self.tableView.register(AccountsTableViewCell.self,forCellReuseIdentifier:cellReuseIdentifier)
解决方法
 从viewDidLoad()中删除以下行(代码),因为您已从故事板连接了Cell. 
  
  
 
        self.tableView.register(AccountsTableViewCell.self,forCellReuseIdentifier: cellReuseIdentifier)
还为身份检查器共享快照(仅在属性检查器的左侧).