0
私は適切なセルdetailedTitleの複数の行テキストを作成しようとしていますが、cell.numberOfLines = 0に設定すると、複数の行が得られますが、セルの正しい間隔はありません。押し出されたばかり場合は、テキストを見ることができるように私は私のプログラムでswift 3:UITable cell multiple lines issue
をそのコードを実行したときに、私は次の結果を取得し、私もcellAutoDimentionsを呼び出して試してみましたが、それは何の違い
cell.detailTextLabel?.numberOfLines = 0
をしませんでしたこのケースでは、セルの境界線のうち、上と下が右辺ではなく、CGRectを変更して修正する方法を知っています。以下は、私のコード
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itorStorage.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.messageField.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MessageCustomCell
cell.backgroundColor = LightBlue
cell.textLabel?.text = itorStorage[indexPath.row].name
cell.textLabel?.textColor = .white
cell.detailTextLabel?.text = itorStorage[indexPath.row].text
cell.detailTextLabel?.textColor = .white
cell.pic.image = itorStorage[indexPath.row].image
cell.timeStamp.text = itorStorage[indexPath.row].time
cell.detailTextLabel?.numberOfLines = 0
cell.detailTextLabel?.lineBreakMode = .byWordWrapping
return cell
}
override init() {
super.init()
messageField.delegate = self
messageField.dataSource = self
messageField.tableFooterView = UIView(frame: CGRect.zero)
messageField.rowHeight = UITableViewAutomaticDimension
messageField.allowsSelection = false
self.messageField.register(MessageCustomCell.self, forCellReuseIdentifier: "Cell")
ratingView.didFinishTouchingCosmos = didTouchCosmos
}
私は、このソリューションを試してみましたが、私は同じ結果 – Sina
はあなたのコード(特に他のテーブルビューのデリゲートとデータ・ソース関数)の多くを追加することができます取得しますか?あなたはheightForRowを実装しましたか?もしそうなら、それを削除してください – mlidal
上記の余分なコードを追加しました! – Sina