I have two UIViewControllers each with their own nib files. Each controller serves a different purpose. The idea was to add a UIScrollController and add both UIViewControllers to it so the user can easily scroll between them both.
Q1) Is this even possible? Or have I got the whole purpose of UIScollControllers incorrect, if so, what is the best alternative.
I have been poking around the internet and the best I can come up with is this:
ScoreViewController *scoreController = [[ScoreViewController alloc] initWithNibName:@"ScoreViewController" bundle:nil];
scoreController.view.frame = CGRectMake(0.0f, 0.0f, 960f, 640f);
[self.scrollview addSubview:scoreController.view];
[scoreController release];
SettingsViewController *settingsController = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
settingsController.view.frame = CGRectMake(0.0f, 0.0f, 960f, 640f);
[self.scrollview addSubview:settingsController.view];
[settingsController release];
This code is entered inside my RootViewController class. It doesn’t seem to work though as I can’t scroll between the two UIViewControllers I have added (score and settings). All what is displayed on the screen is the second controller added – the SettingsViewController.
Q2) Why is this broken?
Thank you. 🙂
Actually you place the first controller correctly, then you put the second above it.
then, you have to set the contentSize of the scrollView
Then enable the paging of the scrollView;
And that should work 🙂