Help us understand the problem. What is going on with this article?

autolayout - UITableView - heightをcontentSizeに一致させる方法

More than 3 years have passed since last update.

 実際に試しているのは「UIScrollViewのなかに置いたUITableViewのheightをcontentSizeに一致させる方法」です。特に検証もしてないので備忘録的メモ…

要旨

  • Storyboardにて、UITableViewにHeight Constraintを設定 (適当な値でよい)
  • @IBOutlet weak var tableView: UITableView! @IBOutlet weak var tableHeight: NSLayoutConstraint! などとアウトレットを設定
  • viewDidAppearで tableHeight.constant = tableView.contentSize.height と書く

 これで(UIScrollViewの中に置いた)UITableViewがコンテンツのサイズぴったりのheightになるようです。
 Autolayout下ではframeを直接書き換えてもダメっぽい?

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away