Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Found a solution here <a href="http://codethink.no-ip.org/wordpress/archives/357" rel="nofollow">ScrollView ContentSize</a>, you will be able to find the sizes of the subviews and find the combined content size and also options to say whether subviews are arranged horizontally or vertically.</p> <p>Here is the code from the link above : </p> <pre><code>@interface UIScrollView(auto_size) - (void) adjustHeightForCurrentSubviews: (int) verticalPadding; - (void) adjustWidthForCurrentSubviews: (int) horizontalPadding; - (void) adjustWidth: (bool) changeWidth andHeight: (bool) changeHeight withHorizontalPadding: (int) horizontalPadding andVerticalPadding: (int) verticalPadding; @end @implementation UIScrollView(auto_size) - (void) adjustWidth: (bool) changeWidth andHeight: (bool) changeHeight withHorizontalPadding: (int) horizontalPadding andVerticalPadding: (int) verticalPadding { float contentWidth = horizontalPadding; float contentHeight = verticalPadding; for (UIView* subview in self.subviews) { [subview sizeToFit]; contentWidth += subview.frame.size.width; contentHeight += subview.frame.size.height; } contentWidth = changeWidth ? contentWidth : self.superview.frame.size.width; contentHeight = changeHeight ? contentHeight : self.superview.frame.size.height; NSLog(@"Adjusting ScrollView size to %fx%f, verticalPadding=%d, horizontalPadding=%d", contentWidth, contentHeight, verticalPadding, horizontalPadding); self.contentSize = CGSizeMake(contentWidth, contentHeight); } - (void) adjustHeightForCurrentSubviews: (int) verticalPadding { [self adjustWidth:NO andHeight:YES withHorizontalPadding:0 andVerticalPadding:verticalPadding]; } - (void) adjustWidthForCurrentSubviews: (int) horizontalPadding { [self adjustWidth:YES andHeight:NO withHorizontalPadding:horizontalPadding andVerticalPadding:0]; } @end </code></pre> <p>Also make sure to have a look at the comments on the blog page as an alternative solution is provided. </p> <p>-anoop</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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