Check out this excellent tutorial on using a UIScrollView
with a UIPageControl
. It should get you going.
http://www.iosdevnotes.com/2011/03/uiscrollview-paging/
The important bit is in the viewDidLoad
:
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];
[subview release];
}
Although this code sample uses ARC
, it still applies. Note that the frame for each subview is offset by the page number self.scrollView.frame.size.width * i
.
Good luck.