2017-06-23 7 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は、私が最初にTableViewCellのラベル表示を表示し、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 

} 

です。

+0

デリゲートに変更

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

のviewDidLoad

、親切に私が編集したと願ってい@UsamaSadiqあなたは –

+0

はあなたが理解することができればより多くを説明します。 –

答えて

1

collectionviewの代理人をtableviewcell内に割り当てる必要があります。クリアされない

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