ios - 我的项目在 tableViewCell 显示标签完成之前显示,CollectionViewCell 在 swit3 中显示内部标签?

标签 ios xcode swift3 uicollectionviewcell uitableview

如何控制在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/

相关文章:

ios - 使用由按钮组成的自定义键盘将文本附加到 UITextField

ios - 如何修复 "App Store Connect Operation ERROR ITMS-90771"

ios 无法识别的选择器发送到实例

ios - 我正在尝试制作一种选择器样式,例如设置中的外观选择器

ios - 带换行符 (\n) 的 AttributedString 无法正常工作

ios - 当应用程序处于非事件/终止状态时,不会调用 openURL 函数

ios - 在 iOS 7 中以编程方式设置按钮边框的颜色

ios - 创建一个自定义分段控件,例如

ios - Swift - 从 URL 下载图像后如何调整 UICollectionViewCell 的大小?

ios - 使用自动增量 Swift 3 在 Firebase 数据库中存储帖子(图像、标题)