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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:14:09+00:00 2026-05-24T02:14:09+00:00

The background: First of all, the background. I’ve created an infinite scrollview by using

  • 0

The background:

First of all, the background. I’ve created an “infinite scrollview” by using an UIScrollView with the width of three pages (0, 1 and 2) and then made sure that the UIScrollView always is centered on page 1 when not being scrolled upon. When you scroll to either page 0 or page 2 and the UIScrollViewDelegate senses that the scrolling ended, the content of all the three pages first switches in the direction that you’ve scrolled and then the UIScrollView instantly moves back to page 1, simulating the effect that you can continue to scroll through an endless stream of pages.

At first, I used a UITextView to display the text content of each page, but pretty soon wanted something more flexible when it comes to styling the text. I therefore ended up using a UIWebView in which I load an NSString containing the styled HTML content I wish to display. This worked perfectly, just the way I wanted it to look.

The problem:

Naturally, it takes longer time to load, parse and show a simple HTML page in a UIWebView than it takes to just load a static text in a UITextView. Because of this, when you’ve scrolled in whatever direction, and the scroll view automatically moves back and switches the content of the pages, you can hint the old content for a tenth of a second before the new one shows.

My solution (that did not work):

I searched for the UIWebViewDelegate in the documentation and found that there’s an event when the page is done loading. I hooked this up to do this:

  1. User scrolls from page 1 to page 2.
  2. UIScrollViewDelegate calls scrollViewDidEndDecelerating, telling page 1 to switch it’s content to the same content currently being displayed at page 2.
  3. UIWebViewDelegate of page 1 calls webViewDidFinishLoad, telling the UIScrollView to move back to page 1 and then switch the content of page 0 and 2.

In my head this would fix this problem, but apparently it’s still not enough. Therefore, I ask you for help. Any ideas? Might be worth mentioning that I’ve had NSLog in all the methods and made sure that they’re being called. If there’s anything else, I’d be glad to answer any questions you have.

Thanks in advance!

View Controller containing UIScrollView:

    // Sense when the UIScrollView stops accelerating
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)sender {
        if(pScrollView.contentOffset.x > pScrollView.frame.size.width) {
            [self switchToNextPost];
        } else if (pScrollView.contentOffset.x < pScrollView.frame.size.width) {
            [self switchToPreviousPost];
        }
    }

    // Update the currentPost variable and switch page 1
    - (void)switchToNextPost {
        [prefs setInteger:[[self getNextKey:nil] intValue] forKey:@"currentPost"];

        [self loadPostWithKey:[self getCurrentKey] atPage:[NSNumber numberWithInt:1] withViewController:currentPage];
    }

    // Update the currentPost variable and switch page 1
    - (void)switchToPreviousPost {
        [prefs setInteger:[[self getPreviousKey:nil] intValue] forKey:@"currentPost"];

        [self loadPostWithKey:[self getCurrentKey] atPage:[NSNumber numberWithInt:1] withViewController:currentPage];
    }

    // Custom delegate function. Scrolls UIScrollView to page 1 and then loads new content on page 1 and 3
    - (void)webViewFinishedLoading {
        [pScrollView scrollRectToVisible:CGRectMake(pScrollView.frame.size.width, 0, pScrollView.frame.size.width, pScrollView.frame.size.height) animated:NO];

        [self loadPostWithKey:[self getPreviousKey:nil] atPage:[NSNumber numberWithInt:0] withViewController:previousPage];
        [self loadPostWithKey:[self getNextKey:nil] atPage:[NSNumber numberWithInt:2] withViewController:nextPage];
    }

View Controller for the subviews being displayed as separate pages in the UIScrollView

    // The delegate shown in previous code
    - (void)webViewDidFinishLoad:(UIWebView *)webView {
        [[self delegate] webViewFinishedLoading];
    }
  • 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-24T02:14:10+00:00Added an answer on May 24, 2026 at 2:14 am

    what you can do , i think, is

    1. populate all three pages with relevant content from the beginning.. (you are probably doing that already)…
    2. when scrolling starts, the next (or previous) page shows up as you scroll..
    3. when scrolling finishes, move the scroll content view to center as you already do, and instead of changing text in each web view, change the frames of the views so that relevant web view (i.e. the one user has scrolled to) remains in the center, and other two are adjusted on both sides
    4. change the content of the both web views (which are not visible) so that they are ready for next scroll movement..

    this would still fail in case of fast scrolling.. but because of the lag in loading content i any approach would file there (i think)
    so you can probably make all web views blank (load nothing) and show an activity indicator in case of fast scrolling..

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

Sidebar

Related Questions

First, some background: I'm developing a web application using Python. All of my (text)
A bit of background first: I am using base code from a remote SVN
First some background: VB.NET 2005 Application that accesses a MS-SQL back-end, using multiple Web
First a little background, I'm using jdk 1.6. I've got a 2 column table
First of all, I'm not entirely sure if this fits into stackoverflow, or should
Background / Disclaimer First of all, please feel free to skip this entirely if
Background First of all, much gratitude to atebits for their very informative blog post
Background information first: We are using a strongly-typed DataSet to manage transaction files. That
First of all bit of background. We are developing an application which receives messages
First of all a little background of my problem, i'm trying to identify how

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.