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

  • Home
  • SEARCH
  • 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 8769073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:14:20+00:00 2026-06-13T17:14:20+00:00

I have a view controller than contains a UIScrollView at the top half of

  • 0

I have a view controller than contains a UIScrollView at the top half of the screen. On the bottom half I have a label. This is the detail view for a table, so once you select an item from the table, it loads this detail view. Some of the items you select have different variations so this is where the scroll view comes in. You can scroll left and right to see the variations.

I am trying to have the label BELOW the scroll view change its text when the scroll view scrolls. Here is what I am using to detect which page I am on:

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

This returns the “page number” of the scroll view. How can I tell the label to change it’s text when the user scrolls to a different page? I have looked at a lot of examples including custom delegates, but I just cant seem to find a good solution.

As a side note, the titles to be displayed are in an array so objectAtIndex:page - 1 will be perfect once I can find a way to tell the label (and any others that might be displayed in the future) to update.

  • 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-13T17:14:21+00:00Added an answer on June 13, 2026 at 5:14 pm

    Why not give this a try:

    #define ScrollObjWidth 320.0f // Note: Use what size you need!
    
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView; {
      float roundedValue = round(scrollView.contentOffset.x / ScrollObjWidth);
      _label.text = [NSString stringWithFormat:@"%d", ((int)roundedValue - 1)];
    }
    

    Make sure that your UIViewController is a UIScrollViewDelegate, and that the UIScrollView has it’s delegate property set to the UIViewController.

    Hope that Helps!

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

Sidebar

Related Questions

I have view controller, into the view i have put a table view, and
i have view controller which contains a button which show the image library ,if
I have a view controller based app that contains several views that I display/hide
I have a View controller displaying some information (not table views). I have an
I have one view controller which contains two views (redView, blueView). The views are
Following setup causes trouble: In my storyboard I have a standard table view controller,
I have a view controller with a scrollview with lots of text boxes, when
I have a view controller that houses a UIWebView. I want to display an
I have two view controller classes in my application delegate. I can change from
I have a view controller and I am intercepting the touches on links within

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.