views:

1296

answers:

1

Hello!

I'm about to create an App.

It should have 3 main pages. So I thougt i realize this with a PageControl.

I crated 3 Views and now i stuck on the implementation of this PageControl.

Has anyone a good tutorial or a examplecode where i can look at (it can be german too)?

Thanks, Michael

+2  A: 

Here's a simple idea of how to use it.

PageController.h:

#import <UIKit/UIKit.h>

@interface PageController : UIViewController {
    NSArray * views;
    UIPageControl *pageControl;
}

@property (nonatomic, retain) IBOutlet pageControl;

- (IBAction) changePage:(id)sender;
- (void) animateToView:(UIView *)newView;

@end

PageController.m:

#import "PageController.h"

@implementation PageController

- (void)viewDidLoad {
    [super viewDidLoad];
    pageControl.numberOfPages = [views count];
    pageControl.currentPage = 0;

    // Either wire this up in Interface Builder or do it here.
    [pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
}

- (IBAction) changePage:(id)sender {
    UIView * newView = [views objectAtIndex:[pageControl currentPage]];
    [self animateToView:newView];
}

- (void) animateToView:(UIView *)newView {
     // You'd have to implement this yourself
}

@end
Cory Kilger