Permalink
Browse files

Set content size automatically - don't use magic number

  • Loading branch information...
1 parent 14c419f commit 9ee481cb06322ba01c3a838240fc09c6ed0dc143 @michaeltyson committed Mar 12, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 TPKeyboardAvoidingSample/FirstViewController.m
@@ -23,7 +23,12 @@ - (void)viewDidLoad
{
[super viewDidLoad];
- [self.scrollView setContentSize:CGSizeMake(320, 520)];
+ // Calculate content size given contents
+ CGRect contentRect = CGRectZero;
+ for ( UIView *subview in self.scrollView.subviews ) {
+ contentRect = CGRectUnion(contentRect, subview.frame);
+ }
+ self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width, CGRectGetMaxY(contentRect)+10);
}

0 comments on commit 9ee481c

Please sign in to comment.