cant return cell in cellForRowAtIndexPath

后端 未结 4 1673
北荒
北荒 2021-01-15 15:44

i\'m trying to return different cells in a tableView. Normally in this case i would return different cells and then return nil at the bottom, but in this case it gives me an

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 15:52

    You are only declaring the last var cell: UITableViewCell! - you are not initialising it. You need to do something like

    var cell = UITableViewCell(style: someStyle, reuseIdentifier: someID)
    return cell
    

提交回复
热议问题