Reputation: 14393
I want to implement a paging UIScrollView
that will scroll in both directions (vertically, and horizontally). The default behaviour of UIScrollView is to be one, or the other. Not both.
Is it possible to implement a UIScrollView that would allow paging in both directions? For example, the user would be able to scroll left and up for the previous page with paging in UIScrollView, right and down for the next page.
I can use UIScrollView to implement scrolling horizontally with paging but I can't see how UIScrollView can be scrolled in both directions while paging. How could I implement this behaviour? UIScrollView ? or CAScrollLayer? or anything else?
Any suggestion are appreciated.
Upvotes: 2
Views: 918
Reputation: 18657
You seem to be talking about two different things here: scrolling and paging.
Scrolling is just flicking around to move the screen's viewport over a view that is larger than the screen itself. Normally you set this up by giving a UIScrollView
a subview that is larger than it, and setting the UIScrollView
's contentSize
to the size of the larger thing.
There's nothing magic about it. If contentSize
is taller than the UIScrollView
's size, the scroll view will scroll vertically. If contentSize
is wider, it will scroll horizontally. If contentSize
is both taller and wider, then you'll scroll both vertically and horizontally.
Paging is a different matter. To know how to make it so "you can scroll left and up for the previous page", we'll need to know what a page looks like in your program, how it's represented, etc. From the small description you're giving, I think UIScrollView
probably isn't the way to go. Instead, look into UIPanGestureRecognizer
and some sort of animated transition between views?
But if that doesn't help, you'll need to give us some more details to work with.
Upvotes: 3