LoginSignup
28
25

More than 5 years have passed since last update.

Xcode 6.3 で UITableViewAutomaticDimension が有効にならない場合

Last updated at Posted at 2015-04-11

これまではUITableViewCellの高さの自動計算は、以下のようにUITableViewのrowHeightで設定できましたが、Xcode 6.3 & iOS 8.3 & Swift 1.2 & iOS Simulator 8.3環境(どれが原因か不明)で動作しなくなっていました。

self.tableView.rowHeight = UITableViewAutomaticDimension

原因はよくわかりませんが、とりあえず以下で動作しています。

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

override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}
28
25
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
25