可変になるものとならないものがある
1番最初の長文だけ長くなるが、それ以降のは全て1行になってしまう
謎です。
Swift
1 func tableView(_ table: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 2 // セル生成 3 let cell = table.dequeueReusableCell(withIdentifier: "chatCell", for: indexPath) as! ChatTableViewCell 4 let text = cell.viewWithTag(3) as! UITextView 5 6 // paddingを消す 7 text.textContainerInset = UIEdgeInsets.zero 8 text.textContainer.lineFragmentPadding = 0 9 text.text = (messageArr[indexPath.row]["message"] as! String) 10 11 12 // これではできないのか? 13 text.delegate = self 14 let height = text.sizeThatFits(CGSize(width: text.frame.size.width, height: CGFloat.greatestFiniteMagnitude)).height 15 text.heightAnchor.constraint(equalToConstant: height).isActive = true 16 17 return cell 18 } 19// コメントアウト外すと全て1行になります 20 //func tableView(_ table: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 21 // return 49 22 //} 23 24 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { 25 return 49 //自動設定 26 }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/07 11:01
2019/04/07 11:25
2019/04/07 11:52
2019/04/07 12:07 編集
2019/04/07 12:21 編集
2019/04/11 07:32