Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView上的SIGABRT_Ios_Uitableview_Swift_Sigabrt - Fatal编程技术网

Ios UITableView上的SIGABRT

Ios UITableView上的SIGABRT,ios,uitableview,swift,sigabrt,Ios,Uitableview,Swift,Sigabrt,我有一段代码,是从默认的MasterDetail应用程序中复制出来的,但是当我运行程序时,它会在单元格声明行上暂停。我不知道为什么 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("Cell",

我有一段代码,是从默认的MasterDetail应用程序中复制出来的,但是当我运行程序时,它会在单元格声明行上暂停。我不知道为什么

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell

    let object = objects[indexPath.row].title as String
    cell.textLabel.text = object
    return cell
}
您没有在表视图上注册要使用的单元格

我希望你忘了做这件事

self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
如果您没有为tableview注册单元格,那么它可能会向单元格返回nil

苹果说

let == Constant

var == variable values at any time
那么使用什么呢?将视为可选的

你应该像这样

override func viewDidLoad() {
    super.viewDidLoad()

    self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}


func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {

    var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)

    //OR

    //var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("Cell") as? UITableViewCell

    //Your stuff

    return cell
}
根据,您可能需要检查故事板上的表视图

查找表视图的属性检查器,并验证内容字段是否设置为动态原型。更新这个为我修复了它

另外,打开引擎盖时,请验证表视图中是否有单个表单元格,并确保其标识符字段设置为案例单元格中tableView.dequeueReusableCellWithIdentifier方法调用中的值