0
我在我的表格视图中有两个自定义的可重用表格视图单元格。第一个细胞,我希望它始终在场。第二个单元以及之后,正在返回从mysql数据库传递的计数。在tableview中显示两个可重用的单元格Swift 3
// return the amount of cell numbers
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return posts.count
}
// cell config
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row < 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! InfoCell
//set the data here
return cell
} else {
let Postcell = tableView.dequeueReusableCell(withIdentifier: "PostCell", for: indexPath) as! PostCell
let post = posts[indexPath.row]
let image = images[indexPath.row]
let username = post["user_username"] as? String
let text = post["post_text"] as? String
// assigning shortcuts to ui obj
Postcell.usernameLbl.text = username
Postcell.textLbl.text = text
Postcell.pictureImg.image = image
return Postcell
}
} // end of function
我的第一个细胞是存在的,所以是post.count,但由于某些原因,posts.count缺少一个职位,我相信这是因为第一个单元格中。任何人都可以帮助我吗?提前致谢。