views:

20

answers:

1

Hi,

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 images.

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.

+1  A: 

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.

Altealice
thats great. the psuedocode is similar to mine. Do you know how i can buffer the images? load them and so on? and how to attach them to uiscrollview? sorry for my noobness
Pavan
Load the images normally. Add them as a subview of the UIScrollView and position the center such that they are just outside the bounds of the screen. You know that you are doing this right if you try to move the current image to one side and the buffered image peeks into view, like a magazine app.
Altealice