Simple UITableView in Swift - unexpectedly found nil

后端 未结 13 1606
旧巷少年郎
旧巷少年郎 2020-12-06 00:38

Pretty simple code:

func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
    return 1
}

func tableView(tableView:UITableView!, numberOfRows         


        
13条回答
  •  庸人自扰
    2020-12-06 01:21

    Try doing this:

    let cell = tableView.dequeueReusableCellWithIdentifier("BookCell", forIndexPath: indexPath) as! BookTableViewCell
    

    and don't forget to set the reuse identifier in your storyboard

提交回复
热议问题