Welcome to the iMore Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 1 of 1
  1. Thread AuthorThread Author   #1  
    cinek's Avatar
    iPhone Newbie

    15 Posts
    Global Posts
    341 Global Posts

    Default help with page control

    I'm trying to get pagecontrol to work. Right now I can scroll to the 2nd page, but the background is not changing (im changing the background to make sure it works fine). When I use pageControl to flip through pages, the background changes fine. I think I need to call pageTurning in scrollViewDidScroll but adding [self pageTurningage]; does not work

    this is what I have atm:

    static int kNumberOfPages = 2;
    #import "AppDelegate.h"
    @implementation AppDelegate
    @synthesize window = _window;
    @synthesize pageControl, scrollView, viewControllers;
        pageControlUsed = YES;
    -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
        pageControlUsed = NO;
    -(void)scrollViewDidScroll:(UIScrollView *)sender
        CGFloat pageWidth = scrollView.frame.size.width;
        int page = floor((scrollView.contentOffset.x - pageWidth / 2)/pageWidth) + 1;
        pageControl.currentPage = page;
    -(void)pageTurning:(UIPageControl *)pageController{
        NSInteger nextPage = [pageController currentPage];
        switch (nextPage) {
            case 0:
                scrollView.backgroundColor = [UIColor blueColor];
            case 1:
                scrollView.backgroundColor = [UIColor redColor];
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, scrollView.frame.size.height);
        scrollView.delegate = self;
        [pageControl addTarget:self action:@selector(pageTurning:) forControlEvents:UIControlEventValueChanged];
        pageControl.currentPage = 0;
        [self pageTurning:pageControl];
        //self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        //self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        return YES;
    any ideas?

Posting Permissions