2017-06-15 14 views
1

助けてくれてありがとう。tableViewの高さが真のとき高さ

私はNibを使ってTablViewCellを処理しますが、cell.contentViewでグラフィックスを描画しようとするとawakeFormNib()で実際の高さを取得できません。グラフィックス。

セルはダイナミックセルで、私はUITableViewCell + FDTemplateLayoutCellを使用します。

答えて

0

あなたは、セルサブクラスでこれを追加し、真の高さを取得することができます:

-(void)layoutSubviews { 
    [super layoutSubviews]; 

    // Get frame: self.contentView.frame 
} 

と負荷ペン先セルを。まず、ペン先登録:

[self.tableView registerNib:[UINib nibWithNibName:@"CustomCellNibName" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CustomCellReuseIdentifier"]; 

tableView:cellForRowAtIndexPathの負荷ペン先を:

id cell = [self dequeueReusableCellWithIdentifier:@"CustomCellReuseIdentifier"]; 

if (cell == nil) { 
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCellNibName" owner:self options:nil]; 
    for (id currentObject in topLevelObjects){ 
     if ([currentObject isKindOfClass:[CustomCell class]]){ 
      cell = currentObject; 
      break; 
     } 
    } 
} 

あなたはスウィフトに変換することができます信じています。

When is layoutSubviews called?

+0

ので、私はペン先を使用する場合、私はiPhoneとセルサイズの異なるサイズをドラッグして、私は電話でデモを実行すると、最初のサイズもlayoutSubviews基金では、ペン先のセルサイズではなく、携帯電話のサイズですどのようにしてペン先に真のサイズを設定できますか? – Eggplant

+0

@Eggplantどのようにセルを初期化しますか? – tomfriwel

+0

はNibを登録します。 – Eggplant

関連する問題