【发布时间】:2019-07-08 19:14:13
【问题描述】:
我在表格视图单元格内遇到了嵌套集合视图的问题。内容是从在线数据库上传的,需要一段时间才能获取数据。我的问题是如何继续为 Collection View 重新加载数据,直到从在线数据库中获取内容然后显示它。
class DiscoverViewCell: UITableViewCell {
@IBOutlet weak var categoryLabel: UILabel!
@IBOutlet weak var _collectionView: UICollectionView!
@IBAction func seeMoreAction(_ sender: Any) {
}
}
class MovieCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var moviePicture: UIImageView!
@IBOutlet weak var movieTitleLabel: UILabel!
func updateCollectionCell(movie: MovieModel){
moviePicture.image = movie.poster
movieTitleLabel.text = movie.name
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MovieCell", for: indexPath) as? MovieCollectionViewCell else {
return UICollectionViewCell()
}
cell.updateCollectionCell(movie: movieArray[indexPath.item])
return cell
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "DiscoverCell") as? DiscoverViewCell else {
return UITableViewCell()
}
cell.categoryLabel.text = categories[indexPath.item]
setUpCell(cell)
return cell
}
【问题讨论】:
标签: swift uitableview uicollectionview uicollectionviewcell