2017-06-23 46 views
0

如何控制TableViewCell標籤顯示之前,我的CollectionViewCell標籤是否顯示? 我的CollectionViewCell在TableViewCell中。我的項目在tableViewCell顯示標籤完成前顯示,CollectionViewCell在swit3顯示內部標籤?

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標籤和圖像。

+0

不清晰,親切地解釋更多,如果你能 –

+0

@UsamaSadiq我編輯,並希望您能理解。 –

回答

1

您需要在tableviewcell中指定collectionView的委託。

在viewDidLoad中

cell.collectionView.delegate = nil 
cell.collectionView.datasource = nil 

變化代表

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