Swift3 Nib必须仅包含一个顶级对象,该对象必须是swift中的UITableViewCell实例

Swift3 Nib必须仅包含一个顶级对象,该对象必须是swift中的UITableViewCell实例,swift3,nib,custom-cell,Swift3,Nib,Custom Cell,我正在使用一个自定义的CustomTableViewCell。当我尝试运行我的代码时,我得到了这个异常堆栈,我无法理解问题的根源: terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid nib registered for identifier (ID) - nib must contain exactly one top level object which

我正在使用一个自定义的
CustomTableViewCell
。当我尝试运行我的代码时,我得到了这个异常堆栈,我无法理解问题的根源:

terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid nib registered for identifier (ID) - nib must contain exactly one top level object which must be a UITableViewCell instance'
在CustomTableViewCell中,一个xib文件中有两个单元格,我给出了不同的标识符

某段代码

 override func viewDidLoad() 
{
    super.viewDidLoad()

let nib = UINib(nibName:"CustomTableViewCell", bundle:nil)
tableview.register(nib, forCellReuseIdentifier:"ID")
tableview.register(nib, forCellReuseIdentifier:"ID2")

}
之后

func tableView(_tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell  {

    if indexPath.row == 0
    {

     let cell  = tableView.dequeueReusableCell(withIdentifier:"ID") as! CustomTableViewCell

                cell.textLabel.text = "TEXT"
                cell.detailTextLabel.text = "DETAIL TEXT"

         return cell
     }
else
    {
    let cell  = tableView.dequeueReusableCell(withIdentifier:"ID2") as! CustomTableViewCell

                cell.imageView.image = UIImage(named:"image.png")

    return cell

    }

  }

是否确实已将
UITableViewCell
创建为xib文件?它必须是您的XIB文件名。@Janaknimal是的,我已创建为XIBfile@JanakNirmal,你能帮我吗?那个xib文件的名字是什么?您需要输入该文件名而不是
UITableViewCell
@JanakNirmal,我已经输入了该文件名而不是UITableViewCell,请告诉我们答案