2016-03-30 3 views
0

私はアプリを作るためにXcodeを使用しています。自動レイアウトを使用すると、ナビゲーションコントローラに組み込まれたビューコントローラの一部であるコンテナビューにtableviewが含まれています。ラベルに合わせてテーブルビューセルを設定するにはどうすればよいですか?

このテーブルビューはコンテンツページなので、個々のテーブルビューセルは、表示したい情報の大部分を含む別のテーブルビューにつながります。

各テーブルビューセルに単語の段落を含むUIlabelを追加し、それぞれのテーブルビューセルに制約を設定しました。

ストーリーボードでは、すべての段落を表示する必要があります。私は行を0に設定し、単語を折り返します。

私は4sシミュレータを使ってプログラムを実行すると、テーブルビューのセルは段落全体を表示するのではなく、各段落の末尾に "..."を表示するだけです。

携帯電話の特定の画面サイズを与えるラップされた後、テーブルビューセルがUIlabelに従って調整されるように設定するにはどうすればよいですか?

PS:私はSWIFTプログラミングの初心者です。ありがとうございました。

答えて

0

あなたがこれを行っているがこれは自己サイズテーブルビューのセルのために必要とされる

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

?:します。また、次のことを確認してください。

A)UILabelの行数が0

Bに設定されている)テーブルビューセル内の自動レイアウトシステムが適切である - すべてのビューは、すべての側面に固定されていますオートレイアウトはセルの高さを正確に決定することができます。

c)効率を高めるためにtableView.estimatedRowHeight = 75(または推定高さ)も行います。

0

この2行をviewDidLoadメソッドに追加し、行番号0のラベル番号と任意の高さを指定しないでください。

func viewDidLoad() { 
    super.viewDidLoad() 

    tableView.estimatedRowHeight = 44.0 
    tableView.rowHeight = UITableViewAutomaticDimension 

} 
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! CustomCell 
    //cell.customTexLabel Number 0f lines 0 and dont give height contrains just Leading,Trailing,TOP and Bottom. 
    cell.customTextLable?.text = "Here index starts from 0 which means first element can be accessed using index as 0, second element can be accessed using index as 1 and so on. Let's check following example to create, initialize and access arrays:Here index starts from 0 which means first element can be accessed using index as 0, second element can be accessed using index as 1 and so on. Let's check following example to create, initialize and access arrays:Here index starts from 0 which means first element can be accessed using index as 0, second element can be accessed using index as 1 and so on. Let's check following example to create, initialize and access arrays:" 

    return cell 
} 
関連する問題