Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

ScrollView within UITabBarController

I for the life of me still can't get a scrollview to work. I'm going back and redoing my UI in code.

AppDelegate.m

UITabBarController *tabBarController = [[UITabBarController alloc] init];
    WeightCalculatorViewController *weightCalcVC = [[WeightCalculatorViewController alloc] init];
RoundCounterViewController *roundCountVC = [[RoundCounterViewController alloc] init];
    NSArray *controllers = [NSArray arrayWithObjects:weightCalcVC, roundCountVC, nil];
    tabBarController.viewControllers = controllers;
    self.window.rootViewController = tabBarController;
    UITabBarItem *weightCalcTab = [[UITabBarItem alloc] initWithTitle:@"Calculator" image:nil tag:0];
    UITabBarItem *counterTab = [[UITabBarItem alloc] initWithTitle:@"Rounds" image:nil tag:1];
    weightCalcVC.tabBarItem = weightCalcTab;
    roundCountVC.tabBarItem = counterTab;

WeightCalculatorViewController.m

CGRect frameSize = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
    self.scrollView = [[UIScrollView alloc] initWithFrame:frameSize];
    self.scrollView.contentSize = CGSizeMake(self.view.bounds.size.width * 2, self.view.bounds.size.height);
    self.scrollView.pagingEnabled = YES;
    self.scrollView.clipsToBounds = NO;
    self.scrollView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.scrollView];

This is the only thing keeping my app from being exactly the way I want it. Please help!

Sorta got it fixed. I was adding subviews to the wrong views. I'll have to check it again once I replace all the UI elements but I think I've got it.