Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just ran into a similar situation (UIScrollView -> UITableView) and was banging my head against it for hours. The short answer is this: the correct sizes to use as the basis of sizing things out were not available until my ViewController (governing the UIScrollView) was sent <code>viewWillAppear:</code>. Before then, I found that the values were set, but often wrong. (E.g., my first attempt at doing this was in <code>viewDidLoad:</code>, and the sizing values <em>were</em> changed there, but they were <em>wrong</em>!)</p> <p>So my solution was thus:</p> <ul> <li>In <code>viewDidLoad:</code> cause your enclosed UITableView to <code>reloadData</code> once you have your data in place.</li> <li><p>in <code>viewWillAppear:</code> do the following (presuming <code>tableView</code> is the enclosed UITableView and <code>scrollView</code> is the enclosing UIScrollView):</p> <pre><code>tableView.frame = (CGRect){ tableView.frame.origin, tableView.contentSize }; // Finally, set content size based on the last element in the scrollView // in my case, the last element IS the tableView, yours might be different scrollView.contentSize = CGSizeMake(scrollView.width - scrollView.contentInset.left - self.scrollView.contentInset.right, tableView.top + tableView.height); </code></pre></li> </ul> <p>N.B., I was getting some very weird numbers when I checked them before <code>viewWillAppear:</code>; e.g., the tableView.contentSize seemed to be the product of default rowHeight * number of rows, ignoring my custom row heights and excluding any separators! Very odd.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload