如果没有可用数据,如何在特定单元格中显示标签,通知用户?例如,我在tableview单元格中有一个集合视图。我从我的服务器获取信息,以查看用户是否列出了他们喜欢的电影。如果他们没有,我想显示一条消息,说没有选择电影。提前致谢。
// arrays to hold server information
var movies = [AnyObject]()
// tableview cell configuration
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
// declare the header cell
let cell = tableView.dequeueReusableCell(withIdentifier: "MovieDisplayHeader") as! MovieChosenByYouTVC
return cell
} else {
// declare the second cell
let cell = tableView.dequeueReusableCell(withIdentifier: "MovieDisplay") as! MovieDisplayTVC
tableView.reloadData()
// reload the collection view data
cell.collectionView.reloadData()
return cell
}
}
} // end of configuring the cell