Scrolling both Horizontal and Vertical
I'm developing an application in which there are 5 picture and they should scroll both way horizontal and vertical. E.G :- If I scroll horizontal from first picture then second picture should display and if I scroll Vertical from second then third should d开发者_运维问答isplay.
Please help if anyone has some idea about it.
Thank you.
Create a UIScrollView and add your pictures (UIImageViews) as subviews to it. Arrange their frames in the desired order, then set the scroll view's contentSize to the total size of your views. The scroll view's bounds and contentOffset determine what is visible.
To better understand how scroll views work imagine that the scroll view is a "window" through which you can see a part of a large canvas (content). The frame of the scroll view is the size of the "window", its bounds is the content. Scrolling changes the bounds' origin, shifting the "window". Zooming changes the bounds' size, affecting how much is visible. To work properly a UIScrollView must know its contentSize (by default it's always (0,0,frame width, frame height)).
I think you should look for Three20 library. In the code samples you will see ScrollViewTestController
. Use the whole code files (.h and .m) and then try to override the flipping part of code to get the same functionality as it is in horizontal direction.
Hope this helps.
Thanks,
Madhup
精彩评论