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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:57:05+00:00 2026-05-26T00:57:05+00:00

I would like to add a page number above the image such as 1

  • 0

I would like to add a page number above the image such as “1 of 50” and description of the image below the image in the scrollview.

I have looked at this LINK but still couldn’t figure out how to make it happen.

here is my sample code of the images scrollview. Im trying to find a sample that can add text and scroll with the images

NSUInteger i;
        for (i = 1; i <= kNumImages; i++)
        {
                NSString *imageName = [NSString stringWithFormat:@"images%d.jpg", i];
                UIImage *image = [UIImage imageNamed:imageName];
                UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

                // setup each frame to a default height and width, it will be properly placed when we call "updateScrollList"
                CGRect rect = imageView.frame;
                rect.size.height = kScrollObjHeight;
                rect.size.width = kScrollObjWidth;
                imageView.frame = rect;
                imageView.tag = i;  // tag our images for later use when we place them in serial fashion
                [scrollView1 addSubview:imageView];
                [imageView release];
        }

UPDATE:

const CGFloat kScrollObjHeight  = 320;
const CGFloat kScrollObjWidth   = 280.0;
const NSUInteger kNumImages     = 50;


- (void)layoutScrollImages
{
UIImageView *view = nil;
NSArray *subviews = [scrollView1 subviews];

// reposition all image subviews in a horizontal serial fashion
CGFloat curXLoc = 0;
for (view in subviews)
{
        if ([view isKindOfClass:[UIImageView class]] && view.tag > 0)
        {
                CGRect frame = view.frame;
                frame.origin = CGPointMake(curXLoc, 0);
                view.frame = frame;

                curXLoc += (kScrollObjWidth);
        }
}
- (void)viewDidLoad {

        self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];

        // 1. setup the scrollview for multiple images and add it to the view controller
        //
        // note: the following can be done in Interface Builder, but we show this in code for clarity
        [scrollView1 setBackgroundColor:[UIColor blackColor]];
        [scrollView1 setCanCancelContentTouches:NO];
        scrollView1.indicatorStyle = UIScrollViewIndicatorStyleWhite;
        scrollView1.clipsToBounds = YES;        // default is NO, we want to restrict drawing within our scrollview
        scrollView1.scrollEnabled = YES;

        // pagingEnabled property default is NO, if set the scroller will stop or snap at each photo
        // if you want free-flowing scroll, don't set this property.
        scrollView1.pagingEnabled = YES;

        // load all the images from our bundle and add them to the scroll view
        NSUInteger i;
        for (i = 1; i <= kNumImages; i++)
        {
                NSString *imageName = [NSString stringWithFormat:@"creative%d.jpg", i];
                UIImage *image = [UIImage imageNamed:imageName];
                UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

                // setup each frame to a default height and width, it will be properly placed when we call "updateScrollList"
                CGRect rect = imageView.frame;
                rect.size.height = kScrollObjHeight;
                rect.size.width = kScrollObjWidth;
                imageView.frame = rect;
                imageView.tag = i;  // tag our images for later use when we place them in serial fashion
                [scrollView1 addSubview:imageView];
                [imageView release];
        }

        [self layoutScrollImages];

I wanted to put this but unable to find the correct position or right offset to display at the top

UILabel * topLabel = [[UILabel alloc] init];
            topLabel.text = [NSString stringWithFormat:@"%d of %d", i, kNumImages];
            rect.origin.x = offset;
            rect.size.height = 30; // however large you need the label to be
            topLabel.frame = rect;
            offset += 30;
  • 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-05-26T00:57:06+00:00Added an answer on May 26, 2026 at 12:57 am

    I would think something like this would work:

        float offset = 0;
        for (NSUInteger i = 1; i <= kNumImages; i++)
        {
                // load up the image
                NSString *imageName = [NSString stringWithFormat:@"images%d.jpg", i];
                UIImage *image = [UIImage imageNamed:imageName];
                UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    
                // image.size is important here and used to determine placement
                CGRect rect = imageView.frame;
                rect.size = image.size;
    
                // create top label, just basic will need to configure other settings like font
                UILabel * topLabel = [[UILabel alloc] init];
                topLabel.text = [NSString stringWithFormat:@"%d of %d", i, kNumImages];
                rect.origin.x = offset;
                rect.size.height = 30; // however large you need the label to be
                topLabel.frame = rect;
                offset += 30; // adding the label height
    
                // set image frame since we now know the location below top label            
                rect.size = image.size;
                rect.origin.x += offset;
                imageView.frame = rect;
                imageView.tag = i;
                offset += image.size.height; // adding image height
    
                // add bottom label below image
                UILabel * bottomLabel = [[UILabel alloc] init];
                bottomLabel.text = imageName; // just a sample description
                rect.origin.x += offset;
                rect.size.height = 30; // however large you need the label to be
                bottomLabel.frame = rect;
                offset += 30; // adding the label height
    
                [scrollView1 addSubview:topLabel];
                [scrollView1 addSubview:imageView];
                [scrollView1 addSubview:bottomLabel];
                [imageView release];
                [topLabel release];
                [bottomLabel release];
    
                offset += 20; // arbitrary spacing between images
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have own project and i would like add for this class same as
So I have a page where I would like to be able to add
I have got four routes defined like this: //Project list with page number routes.MapRoute(
I would like to add <asp:image> from my codebehind onto the page. The user
I have a ListView and each item have a TextView. I would like add
I would like to add up the number of line changes in an SVN
I would like to add a regular expression character dot . and such a
I would like to add pagination to a page that renders dynamic data. But
I have URLs like: 1) http://www.example.com/?page=2 2) http://www.example.com/my-photos-folder?page=3 Here page number will increase sequentially
I would like to add a GestureDetector to all views (view groups) of an

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.