Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes there is a delegate for this, you need to use the UIScrollViewDelegate.</p> <p><a href="http://developer.apple.com/library/IOS/#documentation/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html" rel="nofollow">http://developer.apple.com/library/IOS/#documentation/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html</a></p> <p>The method scrollViewDidScroll tell you when a scroll append, so in this function you could test the contentOffset property (<em>scrollview.contentOffset.x</em>) and then compare it with your view position and size (<em>myView.frame.origin.x + myView.frame.size.width</em>).</p> <p>So basicaly you should do</p> <pre><code>if(scrollview.contentOffset.x &gt; (myView.frame.origin.x + myView.frame.size.width)) //Remove my view to reuse it </code></pre> <p>If you only have 2 views to display and just want to re-use each view you could find the view currently displayed like this:</p> <pre><code> //Assuming your views had the same width and it is store in the pageWidth variable float currPosition = photoGalleryScrollView.contentOffset.x; //We look for the selected page by comparing his width with the current scroll view position int selectedPage = roundf(currPosition / pageWidth); float truePosition = selectedPage * pageWidth; int zone = selectedPage % 2; BOOL view1Active = zone == 0; UIView *nextView = view1Active ? view2 : view1; UIView *currentView = view1Active ? view1 : view2; //We search after the next page int nextpage = truePosition &gt; currPos + 1 ? selectedPage-1 : selectedPage+1; //then we compare our next page with the selectd page if(nextpage &gt; selectedPage){ //show next view } else{ //show previous view } </code></pre> <p>After that you need to add some content to nextView, add it to the scroll view and remove currentView when its hidden.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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