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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:40:56+00:00 2026-05-23T16:40:56+00:00

I have an iPhone application that is supposed to show images inside a UIScrollView.

  • 0

I have an iPhone application that is supposed to show images inside a UIScrollView. I thought that I could add the UIScrollView manually using Interface Builder and then add images using UIImageView.

Am I approaching this incorrectly? For example, should I just be adding images to the UIScrollView directly?

Here’s my code:

- (void)request:(FBRequest *)request didLoad:(id)result {

    //Code for array of photos
    NSArray *photoAlbumArray=(NSArray*)[result valueForKey:@"data"];
    arrayCount=[photoAlbumArray count];

    //check to see if I did that correctly
    [self.label setText:[NSString stringWithFormat:@"%i", arrayCount]];

    //should have an array of photo objects and the number of objects, correct?
    scrollWidth = 0;
    scroller.contentSize=CGSizeMake(arrayCount*scroller.frame.size.width, scroller.frame.size.height);

    for (int i = 0; i < arrayCount;i++) {
        CGRect rect = scroller.frame;
        rect.size.height = scroller.frame.size.height;
        rect.size.width = scroller.frame.size.width;
        rect.origin.x = scroller.frame.origin.x + scrollWidth;
        rect.origin.y = scroller.frame.origin.y;
        UIImageView *scrollImageView = [[UIImageView alloc] initWithFrame:rect];
        id individualPhoto = [photoAlbumArray objectAtIndex:i];
        NSLog(@"%@",individualPhoto);
        NSArray *keys=[individualPhoto allKeys];
        NSLog(@"%@",keys);
        NSString *imageURL=[individualPhoto objectForKey:@"source"];
        //here you can use this imageURL to get image-data and display it in imageView  
        NSURL *url = [NSURL URLWithString:imageURL];
        NSData  *data = [NSData dataWithContentsOfURL:url];
        UIImage *img = [[UIImage alloc] initWithData:data];
        //check to make sure the proper URL was passed
        [self.label setText:imageURL];
        scrollImageView.image = img;
        //I have an imageView next to the UIScrollView to test whether that works - it does.
        imageView.image = img;
        [scroller addSubview:scrollImageView];
        [img release];
        [scrollImageView release];
        scrollWidth += scroller.frame.size.width;
    }

    pageControl.numberOfPages=arrayCount;
    pageControl.currentPage=0;
}

Based on this call:

-(IBAction)showAlbum:(UIButton *)sender
{
    //Go goes here to get an album and display it in the UIScrollView
    [_facebook requestWithGraphPath:@"ALBUM_ID/photos" andDelegate:self];    
}

I’m displaying the image in a UIImageView to the left of the UIScrollView (for testing purposes) and the UIImageView works just fine. So that’s why I’m wondering if I’m approaching this wrong or if I just made a mistake in my coding.

Could you please help? Because I’ve been working on this for the past few hours and haven’t gotten any further.

UPDATE – here is what I did based on Chris’ recommendation. it works for me but if there are any issues still please do point them out.

        UIImageView *scrollImageView = [[UIImageView alloc] initWithFrame:[scroller bounds]];
        CGRect rect = scrollImageView.frame;
        rect.origin.x = scrollImageView.frame.origin.x + scrollWidth;
        rect.origin.y = scrollImageView.frame.origin.y;
        scrollImageView.frame = rect;
  • 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-23T16:40:57+00:00Added an answer on May 23, 2026 at 4:40 pm

    Check the frame you’re sending to scrollImageView, in this area of code:

    rect.size.height = scroller.frame.size.height;
    rect.size.width = scroller.frame.size.width;
    rect.origin.x = scroller.frame.origin.x + scrollWidth;
    rect.origin.y = scroller.frame.origin.y;
    UIImageView *scrollImageView = [[UIImageView alloc] initWithFrame:rect];
    

    You’re using the scroller’s frame to place the object, but the scroller’s frame will be IT’S coordinates in it’s PARENT view. So by mixing sets of different coordinates, you’re most likely positioning the scrollImageView outside the scroller’s content area.

    You probably want to use scroller.bounds instead, which is the rectangle for the scroller’s content area.

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

Sidebar

Related Questions

I have an iPhone application that is mostly using standard controls. There is one
I have an iPhone application that's using Navigation Controller to display the top bar
I have an iPhone application that adds new contacts via the Address Book Framework.
I have an iPhone application that reads RSS feeds from a YouTube channel. However,
I have an iPhone application that send datas via wifi on my mac. I
I have a simple iPhone application that is very similar to the Page Control
So I have an iPhone application running that is controlled at the highest level
I have a desktop application that will 'sync' with an iPhone application. The sync
I'm developing an iPhone application that have a TabBarController with two tabs. Each tab
I have an iPhone application with a settings.bundle that handles various settings for my

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.