Created
February 18, 2016 08:44
-
-
Save mr5z/c22746ecee1ae2d53244 to your computer and use it in GitHub Desktop.
UIScrollView as a page container and UIViewController as pages
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]; | |
int pageCount = 2; | |
// int pageWidth = self.view.frame.size.width; | |
// int pageHeight = self.view.frame.size.height; | |
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; | |
for(int i = 0;i < pageCount; ++i) { | |
UIViewController *page = [storyBoard | |
instantiateViewControllerWithIdentifier: | |
[NSString stringWithFormat:@"vcPage%d", (i + 1)]]; | |
// CGRect pageSize = CGRectMake(i * pageWidth, 0, pageWidth, pageHeight); | |
// TourPageView *page = [[TourPageView alloc] initWithFrame:pageSize]; | |
[mScrollView addSubview:page.view]; | |
} | |
mScrollView.contentSize = CGSizeMake( | |
mScrollView.frame.size.width * pageCount, | |
mScrollView.frame.size.height); | |
mScrollView.delegate = self; | |
mPageControl.numberOfPages = pageCount; | |
[mPageControl addTarget:self | |
action:@selector(didPressPageController:) | |
forControlEvents:UIControlEventTouchUpInside]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment