2015-05-05 35 views
0

我有一個桌面單元格,我試圖附加一個AVPlayer。tableviewcell高度和框架大小?

  • 創建的cellForRowAtIndexPath細胞
  • 用於行= 8
  • 設定高度是在heightforrowatindexpath 200,其它行使用默認高度
  • 在cellforrowsatindexpath,如果行== 8,呼叫customCell方法,它創建avplayer和附加到cellview.contentview。我得到通過調用的cellForRowAtIndexPath的cellView:ROW8

然而,當我得到的細胞進行自定義8列,單元格的大小爲0 0 0 0作爲一個結果,我不能在avplayer視圖重視細胞。

這裏是控制檯日誌,請注意創建時的單元尺寸不爲零,但在customCellView返回0。任何想法?

heightforrowatindexpath: row = 8, height = 200.000000 
cellForRowAtIndexPath: row=8 
cell.contentView.frame = {{0, 0}, {320, 199.5}}, cell.frame = {{0, 352}, {320, 200}} 
customCellView: customCell.contentView.frame ={{0, 0}, {0, 0}}, textlabel = (null) 
customCell.frame ={{0, 0}, {0, 0}} 
heightforrowatindexpath: row = 8, height = 200.000000 
+0

你能告訴我們創建單元的代碼嗎? –

回答

1

您是否實施了此方法?

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 

您可以指定特定indexPath中每個項目的大小。這可能是你的問題的答案。

+1

請參閱下面的解決方案 – NSCoder

0

我想通了。我在代碼中犯了一個錯誤。

我的cellForRowAtIndexPath,這反過來又稱爲的cellForRowAtIndexPath得到擺在首位,以定製的細胞稱爲customCell。在這種情況下,cellforrowatindexpath似乎對內部調用返回nil。要麼必須在cellforrowatindexpath中定製單元格,要麼將*單元格傳遞給customizeCell。我使用了後一種方法。