开发者

2 UIScrollView detect current page and loading correct ppage

开发者 https://www.devze.com 2023-01-19 13:30 出处:网络
First part of the question: Detecting current images being displayed in scrollview A and B i want to place two UIScrollViews in my main view. Very simply done. So ive placed UIScrollView A above UISc

First part of the question: Detecting current images being displayed in scrollview A and B

i want to place two UIScrollViews in my main view. Very simply done. So ive placed UIScrollView A above UIScrollView B. so it looks like this:

Graphical representation
________
|  A   |   ScrollViewA is above ScrollViewB  
|______|
|  B   |   ScrollViewB is below ScrollViewA
|______|

There will be images which the user can flick through left and right on both ScrollViews. They both show different set of ima开发者_如何学编程ges.

First i want to know how to detect which image the both scrollviews are on. for both A and B.

so i should be able to detect which images are being displayed on scrollviewA and scrollview B eg: UIScrollView A is on image 12 and UIScrollView B is on image 67.

Second part of the question: Loading images on both scroll view as user scrolls from left and right

Because there will be many images in ScrollViewA that the user can scroll from left to and right; and many images in ScrollViewB that the user can also scroll from left to right; obviously i dont want to load them all into the scroll view. Whats the best way i can load them in a scrollview?

an idea is if a user is on image 5, then the user flicks to the left, then the next image will be 6 so only load that image. and so on.

Can everyone help me on how to implement such a thing. Thank you. All your ideas and help will be appreciated.


On loading images, you can do this:

  1. Load current image
  2. Buffer load next and previous images and position them outside the bounds of the visible view
  3. When user flicks left, move right image into view, unload the left image and buffer a new right image. Do the same thing for the right one.

This way you will only have 3 loaded at a time for a scrollview.

On keeping track of which image is loaded, you have to keep track of that yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消