UITableViewCellのカスタムセルで複数行表示をしたいと思っています。
Labelの行数を0に、rowHeightをUITableViewAutomaticDimensionにしましたが、うまくいきませんでした。
どなたかアドバイス頂きたいです。
###ソースコード
Swift
1import UIKit 2class TableViewCell: UITableViewCell { 3 @IBOutlet weak var contentLabel: UILabel! 4 override func awakeFromNib() { 5 super.awakeFromNib() 6 self.contentLabel?.numberOfLines = 0 7 self.contentLabel?.text = "テスト\nTest" 8 } 9}
Swift
1import UIKit 2 3class TableViewController: UITableViewController { 4 @IBOutlet var tabelView: UITableView! 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 9 tableView.estimatedRowHeight = 50.0 10 tableView.rowHeight = UITableViewAutomaticDimension 11 } 12 13 override func didReceiveMemoryWarning() { 14 super.didReceiveMemoryWarning() 15 } 16 17 override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 18 return 4 19 } 20 21 override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 22 return 1 23 } 24 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 25 let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! TableViewCell 26 return cell 27} 28 29
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。