Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8985003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:14:28+00:00 2026-06-15T21:14:28+00:00

I’m learning iOS programming from a book, and I’ve coded an app to make

  • 0

I’m learning iOS programming from a book, and I’ve coded an app to make a page turn to another page, similar to iBooks. But when I run it in the simulator, when I swipe to the left or right the page doesn’t turn or transition at all. I don’t know why.

My code that I believe is relevant is below. I’ve also attached the whole project in case I’ve missed anything. Basically there’s a UIWebview that is the content for the UIViewController. It gets populated from the model located in the class that acts as the data source for the PageView. Depending on which view controller you go to the appropriate (protocol) method then sets the content in the webview according to the index of the view controller you’re going to.

But, it won’t work, as said:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
    NSUInteger index = [self indexOfViewController:(ContentViewController *)viewController];

    if (index == 0 || index == NSNotFound) {
        return nil;
    }
    else {
        index--;
        return [self viewControllerAtIndex:index];
    }
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
    NSUInteger index = [self indexOfViewController:(ContentViewController *)viewController];

    if (index == NSNotFound) {
        return nil;
    }
    else {
        index--;
        return [self viewControllerAtIndex:index];
    }
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self createContentPages];

    NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin]
        forKey:UIPageViewControllerOptionSpineLocationKey];

    _pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
        navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
        options: options];

    _pageController.dataSource = self;
    [[_pageController view] setFrame:[[self view] bounds]];

    ContentViewController *initialViewController = [self viewControllerAtIndex:0];

    NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];

    [_pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward
        animated:NO
        completion:nil];

    [self addChildViewController:_pageController];

    [[self view] addSubview:[_pageController view]];

    [_pageController didMoveToParentViewController:self];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)createContentPages {
    NSMutableArray *pageStrings = [[NSMutableArray alloc] init];

    for (int i = 1; i <= 10; i++) {
        NSString *contentString = [[NSString alloc] initWithFormat:@"<html><head></head><body><h1>Chapter %d</h1><p>This is the page %d of content displayed using UIPageViewController in iOS 6.</p></body></html>", i, i];
        [pageStrings addObject:contentString];
    }

    self.pageContent = [[NSArray alloc] initWithArray:pageStrings];
}

// Return the data view controller for the given index
- (ContentViewController *)viewControllerAtIndex:(NSUInteger)index {
    if (([self.pageContent count] == 0) || index >= [self.pageContent count]) {
        return nil;
    }
    else {
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];

        ContentViewController *dataViewController = [storyBoard instantiateViewControllerWithIdentifier:@"contentView"];

        dataViewController.dataObject = self.pageContent[index];

        return dataViewController;
    }
}

- (NSUInteger)indexOfViewController:(ContentViewController *)viewController {
    return [self.pageContent indexOfObject:viewController.dataObject];
}

Whole project: http://cl.ly/1B0l3Z1H1616

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:14:29+00:00Added an answer on June 15, 2026 at 9:14 pm

    In the

    - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController 
    

    method, you have

    index--
    

    Try changing it to

    index++
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.