Using UIPageControl as a container UIViewController


My Memory

Setting up the interface

To setup the user interface in Interface Builder, you’ll need to create a UIPageControl and a UIScrollView within a UIViewController, and as many other UIViewControllers as to need.

Setting up the PageViewController class

The PageViewController will contain 2 subview a UIScrollView and a UIPageControl. The UIScrollView will contain the views while the UIPageControl will navigate and control which part of the UIScrollView is visible.
You’ll also need some mechanism for calling addChildViewController: on the view controller, I’m my example I did this by sub-classing PagerViewController, but you could also do this before the view controller is push into view.

So, the public interface should look like this:

@interface PagerViewController : UIViewController 
 
@property (nonatomic, strong) IBOutlet UIScrollView *scrollView;
@property (nonatomic, strong) IBOutlet UIPageControl *pageControl;
 
- (IBAction)changePage:(id)sender;
 
@end

On to the implementation file. First of all, I want to handle all the view appearence at…

View original post 942 more words