Last active
December 23, 2015 18:39
-
-
Save davidyeiser/6677422 to your computer and use it in GitHub Desktop.
Scroll view setup with basic view controller
This file contains 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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Get screen size (e.g. iPhone 4 or 5) | |
CGRect screenSize = [[UIScreen mainScreen] bounds]; | |
// Sets dimensions for the root view and scroll view | |
[self.view setFrame:CGRectMake(0.0, 0.0, screenSize.size.width, screenSize.size.height)]; | |
[scrollView setFrame:CGRectMake(0.0, 0.0, screenSize.size.width, screenSize.size.height)]; | |
// Adds the scroll view as a child of the root view | |
[self.view addSubview:scrollView]; | |
// Adds the main view as a child of the scroll view | |
[scrollView addSubview:mainView]; | |
// Sets scrollable area to be the same dimensions as the main view | |
[scrollView setContentSize:mainView.frame.size]; | |
// Adds a bottom margin to the scroll view so the main view doesn't | |
// abruptly end at the bottom edge | |
[scrollView setContentInset:UIEdgeInsetsMake(0.0, 0.0, 64.0, 0.0)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment