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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:58:34+00:00 2026-05-29T18:58:34+00:00

I am trying to modify Apple’s PhotoScroller example and I encountered a problem that

  • 0

I am trying to modify Apple’s PhotoScroller example and I encountered a problem that I couldn’t solve.

Basically, the PhotoScroller originally loaded a bunch of image in an array locally. I try to modify this and change to it request an image file dynamically from an URL. Once the user scroll to the next page, it will fetch the next image from a new URL.

In order to improve the performance, I wanted to preload the next page so user doesn’t need to wait for the image being downloaded while scrolling to the next page. Once the next page is on current page, the page after that will be loaded and so on…

I’m not quite sure how I can achieve this and I hope someone can show me what to do.

Here is my custom code: (Please refer the full code from Apple’s PhotoScroller example)

tilePage method: (It will be call at the beginning and every time when user did scroll the scrollView)

- (void)tilePages 
{
// Calculate which pages are visible
CGRect visibleBounds = pagingScrollView.bounds;
int firstNeededPageIndex = floorf(CGRectGetMinX(visibleBounds) / CGRectGetWidth(visibleBounds));
int lastNeededPageIndex  = floorf((CGRectGetMaxX(visibleBounds)-1) / CGRectGetWidth(visibleBounds));
firstNeededPageIndex = MAX(firstNeededPageIndex, 0);
lastNeededPageIndex  = MIN(lastNeededPageIndex, [self imageCount] - 1);

// Recycle no-longer-visible pages 
for (ImageScrollView *page in visiblePages) {
    if (page.index < firstNeededPageIndex || page.index > lastNeededPageIndex) {
        [recycledPages addObject:page];
        [page removeFromSuperview];
    }
}
[visiblePages minusSet:recycledPages];


// add missing pages
for (int index = firstNeededPageIndex; index <= lastNeededPageIndex; index++) {


    if (![self isDisplayingPageForIndex:index]) {

        ImageScrollView *page = [self dequeueRecycledPage];
        //ImageScrollView *nextpage = [self dequeueRecycledPage];

        if (page == nil) {
            page = [[[ImageScrollView alloc] init] autorelease];
        }

        [self configurePage:page forIndex:index];
        [pagingScrollView addSubview:page];
        [visiblePages addObject:page];

    }
}   

}

To configure page index and content:

- (void)configurePage:(ImageScrollView *)page forIndex:(NSUInteger)index
{   
//set page index
page.index = index;

//set page frame
page.frame = [self frameForPageAtIndex:index];

//Actual method to call image to display
[page displayImage:[self imageAtIndex:index]];  
NSLog(@"index: %i", index);
}

To fetch image from URL:

- (UIImage *)imageAtIndex:(NSUInteger)index {

NSString *string1 = [NSString stringWithString:@"http://abc.com/00"];
NSString *string2 = [NSString stringWithFormat:@"%d",index+1];
NSString *string3 = [NSString stringWithString:@".jpg"];

NSString *finalString = [NSString stringWithFormat:@"%@%@%@",string1,string2,string3];
NSLog(@"final string is: %@", finalString);

NSURL *imgURL = [NSURL URLWithString: finalString];
NSData *imgData = [NSData dataWithContentsOfURL:imgURL];

return [UIImage imageWithData:imgData];

}

Thanks for helping!
Lawrence

  • 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-29T18:58:40+00:00Added an answer on May 29, 2026 at 6:58 pm

    You can use concurrent operations to fetch images one after another. Using NSOperations, you can set a dependency chain so images are loaded in a serial fashion in the background, or you can have them all downloaded concurrently.

    The problem with large images is that even though you save them in the file system, there is a “startup” time to get the images rendered. Also, in PhotoScroller, Apple “cheats” by having all the images pre tiled for each level of detail. Apple provides no way to render just a Plain ole JPEG in PhotoScroller, so unless you can pre tile it will be of no use to you.

    If you are curious, you can see how to both download multiple images and pre tile them into a temporary file by perusing the PhotoScrollerNetwork project on github.

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

Sidebar

Related Questions

I'm trying to modify the Apple PageControl example (iPhone version) so that UIScrollView is
Hi I'm trying to modify a web page so that it loads faster. Since
I am trying to modify the amcap, an application from Windows SDK's example to
I've been trying to modify the AuditTrail code so that it does not copy
I'm trying to capture a url like the following in an intent: https://example.com/apple/orange?key=value I've
Im trying to modify the class below so that the scrolling text appears behind
I am trying to modify a cookie, specifically the pass_hash cookie that the ipb
I'm trying to modify some code that returns results from the database. Currently the
I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but
I'm trying to modify the class of an element if an ajax call based

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.