2017-08-01 16 views
0

私はテーブルビュー上にwebviewを持っており、各セルには電話番号と電子メール/ウェブサイトアドレスの後ろに余分な空白があります。では、セルから余分な空白を削除/削除して、より見た目を良くする方法を教えてください。Swift 3:どのようにして余分なスペースをTableViewから削除できますか?

私が持っているもののコードはこれです:

self.heightOfTheCell = CGFloat(((heightMul)*32)+4) 

私はこれらの数字をアップ再生する方法があまりにもわかりません。

添付のスクリーンショットをご覧ください。ここで

enter image description here

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 

    if indexPath.section == 0 
    { 
     if heightOfTheCell != nil 
     { 
      return heightOfTheCell 
     }else{ 
      return UITableViewAutomaticDimension 
     } 
    } 
    else{ 
     return UITableViewAutomaticDimension 
    } 



} 


func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { 


     return UITableViewAutomaticDimension 
} 

答えて

0

は、私はそれを行う方法です。

まず、セルの制約を適切に設定します。あなたのViewController

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 
    return UITableViewAutomaticDimension 
} 


func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { 
    return UITableViewAutomaticDimension 
} 
+0

に続い

それ 'heightOfTheCell'は、あなたはそれを削除しようとちょうど' UITableViewAutomaticDimension'ことができ、高さが一定になっているようですか? 問題がまだ発生する場合は、セルに高さを特定の値に強制する制約がある可能性があります。 ここでは、セルの高さを動的に設定する方法について学習しました。 https://www.raywenderlich.com/129059/self-sizing-table-view-cells – Kiester

関連する問題