Note that there are some explanatory texts on larger screens.

plurals
  1. POUIScrollView height vs. UIView height
    primarykey
    data
    text
    <p>In my code I am increasing height of the <code>contentSize</code> of a <code>UIScrollView</code> when the UI orientation changes to landscape in order all views fit there and the user can scroll to see it.</p> <p>In my XIB I have</p> <pre> /UIView - view |- UIScrollView - scrollView |- other subviews that should be scrollable </pre> <p>The scrollView has the same size as the view and its autoresize mask is set to resize in all directions.</p> <p>I noticed that the scrollView's height dimensions are much greater than view's height.</p> <p>E.g. I have some debug logs:</p> <pre> NSLog(@"%@ - self.view.frame=%@, self.view.bounds=%@", NSStringFromSelector(_cmd), NSStringFromCGRect(self.view.frame), NSStringFromCGRect(self.view.bounds)); NSLog(@"self.scrollView.frame=%@, self.scrollView.bounds=%@", NSStringFromCGRect(self.scrollView.frame), NSStringFromCGRect(self.scrollView.bounds)); </pre> <p>and it prints</p> <pre> willAnimateRotationToInterfaceOrientation:duration: - self.view.frame={{0, 0}, {480, 219}}, self.view.bounds={{0, 0}, {480, 219}} self.scrollView.frame={{0, 0}, {480, 399}}, self.scrollView.bounds={{0, 0}, {480, 399}} </pre> <p>And even in the Xcode IB it looks like:</p> <p><img src="https://i.stack.imgur.com/4oqYZ.png" alt="height of UIScrollView vs UIView"></p> <p>Why doesn't the <code>UIScrollView</code> have same size as the view?</p> <p>Thanks</p> <hr> <p><strong>Update</strong></p> <p>The strange thing is that when I set height of the scrollView to 460 (iPhone portrait), Xcode/IB show that the scrollView is smaller than its parent view (which also has set the same dimensions): <img src="https://i.stack.imgur.com/crRlm.jpg" alt="enter image description here"></p> <p>But now I have created a test project with 1 XIB that has only 1 <code>UIView</code>, added in there 1 <code>UIScrollView</code> and it looks normally, the <code>UIScrollView</code>'s height matches the <code>UIView</code>'s.</p> <p>So perhaps I have somehow messed up the XIB and Xcode can't handle it well.</p> <p>Anyway I am setting the dimensions programmatically (to handle rotations, UI composition changes etc.) and it works as expected. As it is my first iOS project, I was just wondering if there is any magic in <code>UIScrollView</code>. Apparently not :-)</p> <p>Thanks for all your comments.</p>
    singulars
    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.
 

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