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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:05:51+00:00 2026-05-23T01:05:51+00:00

I want to display the images present in my database on the Scroll view.Also

  • 0

I want to display the images present in my database on the Scroll view.Also i want to display 4 images in a row then next 4 in next row and so on.Initially the scroll view will show only 2 rows and after scrolling vertically the user will be able to scroll through all the images present in the database.Can anyone suggest any suitable measures to do this or provide any sample demo or code for this.Any help will be appreciated.

I am using this code to get images in horizontal fashion .How can i do it in vertical fashion after 5 images in a row.My code:-

 - (void)layoutScrollImages
 {

     UIImageView *view = nil;
    NSArray *subviews = [scrollView1 subviews];
    CGFloat curXLoc = 40;
// reposition all image subviews in a horizontal serial fashion

//CGFloat curYLoc = 0;
for (view in subviews)
{
    //if ([view isKindOfClass:[UIImageView class]] && view.tag > 0)
    if(view)
    {
        CGRect frame = view.frame;
        frame.origin = CGPointMake(curXLoc, 40);
        view.frame = frame;
        curXLoc += (kScrollObjWidth);           

    }
}

     // set the content size so it can be scrollable
     [scrollView1 setContentSize:CGSizeMake((20 * kScrollObjWidth),[scrollView1 bounds].size.height)];
     //[self layoutScrollLabels];
 }

And in view did load i created scroll view as:-

scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(25,48,630,180)];
[scrollView1 setBackgroundColor:[UIColor lightGrayColor]];
[scrollView1 setCanCancelContentTouches:NO];
//scrollView1.indicatorStyle = UIScrollViewIndicatorStyleWhite;
//scrollView1.clipsToBounds = YES;      // default is NO, we want to restrict drawing within our scrollview
scrollView1.scrollEnabled = YES;
scrollView1.pagingEnabled=YES;
scrollView1.showsVerticalScrollIndicator = YES;
//scrollView1.showsHorizontalScrollIndicator = YES;
//scrollView1.alwaysBounceVertical = YES;
//scrollView1.alwaysBounceHorizontal = NO;

    [self.view addSubview:scrollView1];

Thanks,
Christy

  • 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-23T01:05:52+00:00Added an answer on May 23, 2026 at 1:05 am

    ——Updated——-

    - (void)layoutScrollImages
    {
        //Considered your Image width & height as 50
    
        int i; //Variable to keep count per line;
        CGFloat curXLoc = 10; //Variable to keep X Location track
        CGFloat curXLoc = 0; //Variable to keep Y Location track
        for (UIImageView *tmpImgView in [scrollView1 subviews])
        {
            if(tmpImgView)
            {
                CGRect frame = view.frame;
                frame.origin.x = curXLoc;
                frame.origin.y = curYLoc;
                view.frame = frame;
    
                curXLoc = curXLoc + 55; // Adding 55 for next photo X position
    
                if(i!=1 && i%5 == 0)
                {
                    curXLoc = 10; //Reset X Location so that it will start from left again;
                    curYLoc = curYLoc + 55; // Adding 55 for next photo Y position if 5 photos are placed in one row
                }
            }
            i++;
        }
    
        // set the content size so it can be scrollable
        [scrollView1 setContentSize:CGSizeMake(yourScrollViewWidth,curYLoc+100)];
    }
    

    —–Updated Finished——-

    Here you are,

    -(void)setImagesInScrollView
    {
        scrollView.delegate = self;
    
        int i=1;
        CGFloat cx = 0;
        CGFloat cy = 0;
    
        for(UIImageView *yourImgView in yourImgArray)
        {
            //Create Image
            UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 80)];
            imgView.contentMode = UIViewContentModeCenter;
            imgView.image = yourImgView.image;
    
            CGRect rect = imgView.frame;
            rect.size.height = imgView.frame.size.height;
            rect.size.width = imgView.frame.size.width;
            rect.origin.x += cx;
            rect.origin.y += cy;
            imgView.frame = rect;
    
            cx+=imgView.frame.size.width + 60;
            [scrollView addSubview:imgView];
    
            if(i!=1 && i%6==0)
            {
                cx=62;
                cy+=155;
            }
    
            [imgView release];
            i++;
        }
    
        [scrollView setContentSize:CGSizeMake(1024, cy+150)];
        [scrollView setFrame:CGRectMake(scrollView.frame.origin.x, scrollView.frame.origin.y, 1024, 630)];
        [scrollView setContentSize:CGSizeMake(1024, cy+150)];
        [scrollView setContentOffset:CGPointMake(0.0, 0.0)];
    }
    

    Above code was for iPad setting Images with 100 & 80 width & height respectively. . cx and cy variables are used to keep track for positioning next image. In 1 line here 6 Images are possible (Landscape mode). Modify code for the same as per your requirement.

    If you need further help please leave a comment.

    Hope this helps.

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

Sidebar

Related Questions

I want to display images on a .net page which I load from database
I have a sprite sheet and I want to display images next to each
I have some text/images that I only want to display in the normal state
I want display images in gallery view it want to focus to paticular image
I want to display images in a TableView . I can display one image
I am parsing the public timeline xml from twitter and want to display images
Just looking for a good PHP Image Library, I want to display images with
I want to display about 5-8 images on my page, one by one, but
I want to integrate the Cover Flow for the images display in my iPhone
I have a list of images which I want to display in a page.

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.