Note that there are some explanatory texts on larger screens.

plurals
  1. POUIScrollView Paging with Preloading
    text
    copied!<p>I implemented a paging UIScrollView. Therefore I have got 5 subviews on my scrollview. To have a nice effect I set up a little offset to every subview so that on the first page, you can see a little bit of the second page at the right side of the ipad. The same effect on the other pages, so everytime you are on a page you have got a little preview on the left/right side of your screen. The scrolling between pages works perfect, but the problem is, that at the first time, the preview isn't loaded. I got a textview on every subview, but it loads first after I scroll to the next page. So my preview doesn't work correct. How can I do something like a preloading, so that my other subview pages are loaded before I switch to them?</p> <p>Thanks for your help, I hope I could explain it that its clear... Andy</p> <p><img src="https://i.stack.imgur.com/tMZpb.png" alt="preview page loading"></p> <p>Code:</p> <p>XIB: I have got one UIScrollView, Size 750, 700. My Customview is 700,700.</p> <pre><code>resultScrollView.clipsToBounds = NO; resultScrollView.pagingEnabled = YES; resultScrollView.showsHorizontalScrollIndicator = YES; [resultScrollView addSubview:[self createCustomSubView:0.0f :VIEW_OFFSET_BETWEEN :VIEW_WIDTH :VIEW_HEIGHT]]; [resultScrollView addSubview:[self createCustomSubView.frame.size.width :VIEW_OFFSET_BETWEEN :VIEW_WIDTH :VIEW_HEIGHT]]; [resultScrollView addSubview:[self createCustomSubView:2*resultScrollView.frame.size.width :VIEW_OFFSET_BETWEEN :VIEW_WIDTH :VIEW_HEIGHT]]; [resultScrollView addSubview:[self createCustomSubView:3*resultScrollView.frame.size.width :VIEW_OFFSET_BETWEEN :VIEW_WIDTH :VIEW_HEIGHT]]; [resultScrollView addSubview:[self createCustomSubView:4*resultScrollView.frame.size.width :VIEW_OFFSET_BETWEEN :VIEW_WIDTH :VIEW_HEIGHT]]; resultScrollView.contentSize = CGSizeMake(5*resultScrollView.frame.size.width+5*VIEW_OFFSET_BETWEEN, resultScrollView.frame.size.height); </code></pre> <p>The method:</p> <pre><code>CGRect frame = CGRectMake(contentOffset + betweenOffset, 0.0f, width, height); NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"CustomSubview" owner:self options:nil]; CustomSubview *customSubView = [subviewArray objectAtIndex:0]; CustomSubview.frame = frame; CustomSubview.contentMode = UIViewContentModeCenter; CustomSubview.contentSize = CGSizeMake(VIEW_SCROLLABLE_CONTENT_WIDTH, VIEW_SCROLLABLE_CONTENT_HEIGHT); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload