Cris
Cris

Reputation: 12204

UIScrollView, how to scroll frame by frame in iPhone app?

I would like to show a gallery using a horizontal ScrollView; i would like to show an item and, when the user swipes, animate to a certain position to avoid to see partial images but centering the next item to the screen and "dock" the item to (x,y) coordinates. How can i do it?

Upvotes: 0

Views: 396

Answers (1)

Andrei Stanescu
Andrei Stanescu

Reputation: 6383

I hope I understand this right. When the user swipes, you want to scroll to the next picture (using an animation). Also, the scrollview should then snap on the picture so that it doesn't display any other partial images.

If this is the case, then you can use scrollView.pagingEnabled = TRUE. You will have this snapping (docking) and swiping features implemented.

All you need to do is to arrange the pictures inside the scrollview so that it is only one picture per screen.

If you expect a lot of images, then you can improve this design by storing only the previous, current and next pictures. When the user scrolls from current -> next, then you will have something like this:


previousImage = currentImage;
currentImage = nextImage;
nextImage = //Load the next gallery image

If you need more help, feel free to ask.

Upvotes: 1

Related Questions