I'm trying to make a Scroll View that can page through different colored backgrounds. As of right now, when I attempt to go to that Scroll View, the backgrounds don't show up, leaving me with nothing but a blank screen and no scrolling capabilities. I've spent hours looking online for a solution to this, but nothing seems to work. This is the implementation for my ImageViewController class:
- (void)loadView
{
[super loadView];
NSArray *colors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];
for (int i = 0; i < colors.count; i++) {
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
UIView *subview = [[UIView alloc] initWithFrame:frame];
subview.backgroundColor = [colors objectAtIndex:i];
[self.scrollView addSubview:subview];
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count, self.scrollView.frame.size.height);
[self.view addSubview:scrollView];
}