如何控制在TableViewCell标签显示之前,显示我的CollectionViewCell标签? 我的 CollectionViewCell 在 TableViewCell 中。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! CollectionViewCell
let list = sections[(indexPath as NSIndexPath).row]
DispatchQueue.main.async {
cell.categoryTitle.text = list.package_name
cell.mainAssociatedURL.text = list.package_url
cell.collectionView.tag = indexPath.row
cell.collectionView.reloadData()
}
return cell
}
}
我的 CollectionViewCell 在这里,
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let list = sections[indexPath.row].packageTable[indexPath.row]
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "videoCell", for: indexPath) as! CollecitonViewCell
AsyncImageLoader.sharedLoader.imageForUrl(urlString: list.poster_url) { (image, url) -> () in
DispatchQueue.main.async(){
cell.movieTitle.text = list.name
if(url == StringResource().posterURL){
cell.imageView.image = UIImage(named: "mmcast_cover")
}else{
cell.imageView.image = image
}
}
}
return cell
}
我想先显示 TableViewCell 标签显示,然后再去显示 CollectionViewCell 标签和图像。
最佳答案
您需要在 tableviewcell 中分配 collectionView 的委托(delegate)。
在 ViewDidLoad 中
cell.collectionView.delegate = nil
cell.collectionView.datasource = nil
委托(delegate)变更
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! CollectionViewCell
let list = sections[(indexPath as NSIndexPath).row]
DispatchQueue.main.async {
cell.categoryTitle.text = list.package_name
cell.mainAssociatedURL.text = list.package_url
cell.collectionView.tag = indexPath.row
cell.collectionView.delegate = self
cell.collectionView.datasource = self
cell.collectionView.reloadData()
}
return cell
关于ios - 我的项目在 tableViewCell 显示标签完成之前显示,CollectionViewCell 在 swit3 中显示内部标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44712286/