2016-11-26 103 views
0

为什么下面的代码只显示1到17的单元格?indexPath.row从0到16而不是在

internal func tableView(_ tableView: UITableView,numberOfRowsInSection section: Int) -> Int { 

    return 20 
} 

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

    let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier:"Cell") 


    cell.textLabel?.text=String(indexPath.row+1) 
     print(indexPath.row) 
    return cell 
}` 

输出: enter image description here

+0

吓人。清理,删除派生数据并重试。 – shallowThought

回答

0

请启用您的tableview的滚动,并且在输出向下滚动细胞。