2016-07-20 8 views

答えて

1

書き込みviewDidLoad

+0

plzは以下のコメントで私の問題 – Amitkumar

2
tableView.estimatedRowHeight = 50 
tableView.rowHeight = UITableViewAutomaticDimension 

単に

- (void)viewDidLoad 
{ 
... 
... 
self.tableView.estimatedRowHeight = 100.0; 
self.tableView.rowHeight = UITableViewAutomaticDimension; 
} 

スウィフト

Objective-Cのように使用

override func viewDidLoad() { 


     self.tableView.estimatedRowHeight = 80 
     self.tableView.rowHeight = UITableViewAutomaticDimension 

} 

のObjective-C

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
return 80; // customize the height 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
return UITableViewAutomaticDimension; 
} 

スウィフト

func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 
return 80 // customize the height 
} 

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 
return UITableViewAutomaticDimension 
} 

最終的属性に= 0あなたlabel.numofLinesを設定したり、programtically

+0

が確実 –

+0

plzは、あなたが0にラベルの行番号を設定する必要がコメント – Amitkumar

2

私は理由を知りたいのですがあなたはautolayoutを使わずにメソッドを探していることを知っています。私は、以前は答えが自動レイアウト

self.tableView.estimatedRowHeight = 50; 
self.tableView.rowHeight = UITableViewAutomaticDimension; 

を自動レイアウト使用したソリューションです掲載、あなたが必要とする自動レイアウトがなければ自動レイアウト

なしラベル

の内容に応じて拡張することmultiline labelを設定することができると信じて各セル(height for each labels + margin)の高さを個別に計算し、UITableViewデータソースメソッド- tableView:heightForRowAtIndexPath:の値を返します。

0

おかげしかし問題は が私のテーブルビューは良く見えるが、テキストはあなたの助けを使用した後

  • に調整されていない上記のソリューションを使用せずに画像にする前に

    1. を確認してください解決しない

    enter image description here

    すべてが絵コンテと

    私のテーブルビューを混乱さself.tableView.rowHeight = UITableViewAutomaticDimension;heightforcell方法を使用すると、間違ったが、私はここでやっているいただきましセクション

    enter image description here

    を自動サイズ変更のためにサイズインスペクタ]タブを確認してください?

  • +0

    以下に私の問題をチェックし、あなたが 'self.tableView.estimatedRowHeight =現在の行を使用しないと機能し、いずれかの選択肢を使用して確認してください高さ ' ' –

    関連する問題