Simple UITableView in Swift - unexpectedly found nil

后端 未结 13 1574
旧巷少年郎
旧巷少年郎 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:30

    When you create a view in code, its IBOutlet properties don't get hooked up properly. You want the version that you get back from dequeueReusableCellWithIdentifier:

    let cell = tableView.dequeueReusableCellWithIdentifier("BookCell") as BookTableViewCell
    

提交回复
热议问题