Created
March 19, 2013 22:46
-
-
Save kylehowells/5200854 to your computer and use it in GitHub Desktop.
Automatically set the height of a UIScrollView to fit it's content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGFloat scrollViewHeight = 0.0f; | |
CGFloat scrollViewWidth = 0.0f; | |
for (UIView *view in scrollView.subviews) { | |
CGFloat height = (view.frame.size.height + view.frame.origin.y); | |
scrollViewHeight = ((height > scrollViewHeight) ? height : scrollViewHeight); | |
CGFloat width = (view.frame.size.width + view.frame.origin.x); | |
scrollViewWidth = ((width > scrollViewWidth) ? width : scrollViewWidth); | |
} | |
[scrollView setContentSize:(CGSizeMake(scrollViewWidth, scrollViewHeight))]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi ! How to use this please