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 7775649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:41:14+00:00 2026-06-01T17:41:14+00:00

I have a simple page control set up with two different pages. I have

  • 0

I have a simple page control set up with two different pages. I have a button called nextButton, and if the user hits that button, I want to change the page and scroll to the next page.

My page control works, and I can scroll to change pages, but the button does not work at all. It is getting called though.

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * TUTORIALNUMBEROFPAGES, self.scrollView.frame.size.height);
    self.scrollView.pagingEnabled = YES;
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.scrollsToTop = NO;
    self.scrollView.delegate = self;

    self.pageControl.numberOfPages = TUTORIALNUMBEROFPAGES;
    self.pageControl.currentPage = 0;

    CGRect pageFrame = self.scrollView.frame;
    pageFrame.origin.x = pageFrame.size.width * 0;
    pageFrame.origin.y = 0;

    self.pageOne.frame = pageFrame;
    [self.scrollView addSubview:self.pageOne];

    pageFrame.origin.x = pageFrame.size.width * 1;
    self.pageTwo.frame = pageFrame;
    [self.scrollView addSubview:self.pageTwo];
}

- (void)scrollViewDidScroll:(UIScrollView *)sender 
{    
    if (pageControlUsed) {
        return;
    }

    CGFloat pageWidth = self.scrollView.frame.size.width;
    int page = floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    self.pageControl.currentPage = page;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 
{    
    pageControlUsed = NO;
}

- (IBAction)changePage:(id)sender 
{        
    NSInteger currentPage = self.pageControl.currentPage;
    CGPoint offset = CGPointMake(currentPage * self.scrollView.frame.size.width, 0);
    [self.scrollView setContentOffset:offset animated:YES];
    pageControlUsed = YES;
}

- (IBAction)nextButton:(id)sender
{
    [self changePage:self];
}
  • 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-01T17:41:15+00:00Added an answer on June 1, 2026 at 5:41 pm

    Try something like this:

     - (IBAction)nextPage:(id)sender 
      {        
         NSInteger currentPage = self.pageControl.currentPage + 1;
         CGPoint offset = CGPointMake(currentPage * self.scrollView.frame.size.width, 0);
        [self.scrollView setContentOffset:offset animated:YES];
        pageControlUsed = YES;
     }
    
      - (IBAction)nextButton:(id)sender
      {
          [self nextPage:self];
    
      }
    

    Notice the +1 in that code. Before, you were literally setting the content offset exactley equal to the original offset because you were just taking the value of the page control.

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

Sidebar

Related Questions

I have a simple iPhone application that is very similar to the Page Control
I have a simple form on a view page, implemented as a user control,
I have an ASPNetSpell:SpellTextBox control on my page and if I type a simple
I have a simple page with images, and when the user clicks the image,
I have a simple page layout with two divs--one on top, and one on
I am simply learing Ajax with jQuery and have a simple page method that
I have a simple web page that till now didn't need any login. It
I have a simple asp.net user control: <%@ Control Language=C# AutoEventWireup=true CodeBehind=QueryDefinitionItem.ascx.cs Inherits=xxx.UserControls.QueryDefinitionItem %>
Maybe someone can help me out. I have created a simple web user control,
I have a simple ASP.NET page where after the initial page load the user

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.