基于iOS的APP“好妈妈”开发日志十一——一个tableview中放置多个cell
在 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{}
中进行if判断时必须要在最后留出口即最后一条判断语句必须是else结尾,而不是一直用else if。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
tableView.isScrollEnabled = false //禁止上下滑动
// Configure the cell...
if(indexPath.row == 0){
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell1", for: indexPath)
*********
return cell
}else if(indexPath.row == 1){
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell2", for: indexPath)
*********
return cell
}else{
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell3", for: indexPath)
*********
return cell
}
}
luhh?