我想设置一个表格视图,它将根据顶部的分段控制器更改单元格。但是,在重新加载tableview时试图更改单元格时,实际上我有一个返回函数,我收到了一个返回函数错误。我能做些什么来解决这个问题?缺少函数返回'UITableViewCell',但实际返回两次
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if friendSelector.selectedSegmentIndex == 0 {
print("0")
cell = self.friendsTable.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FriendsTableViewCell
cell.nameLabel.text = friends[indexPath.row]
cell.bacLabel.text = String(friendsBac[indexPath.row])
cell.statusImageView.image = friendsImage[indexPath.row]
return cell
}
if friendSelector.selectedSegmentIndex == 1 {
print("1")
celladd = self.friendsTable.dequeueReusableCell(withIdentifier: "celladd", for: indexPath) as! FriendsAddTableViewCell
celladd.nameLabel.text = requested[indexPath.row]
celladd.statusImageView.image = UIImage(named: "greenlight")
return celladd
}
}
如果两个条件都不令人满意,则该方法不返回任何内容。 –