I am making digital comic now. My application has horizontal paging when without zooming. But when zooming, picture's height is over the screen height. So application has vertical paging.
But I don't need vertical paging. i want to make horizontal paging without vertical paging during zooiming.
Please teach me.
It's really simple. As your friend suggested, you will need AT LEAST two UIScrollView
. You will need one UIScrollView
for the horizontal (i.e. paging), and you will need one UIScrollView
for each page. The key points are (let's name them scrollHorizontal
and scrollVertical
):
scrollHorizontal.frame.height
must equal scrollHorizontal.contentSize.height
(otherwise, you will end up with vertical paging)scrollVertical
: first, you will have one of this for each page. The frame width and contentSize.width
should match and make sense w.r.t. the width of a page (in your scrollHorizontal
). You should of course have the frame height be no more than scrollHorizontal.contentSize.height
.Sample code:
UIScrollView scrollHorizontal = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; scrollHorizontal.pagingEnabled = YES; scrollHorizontal.directionalLockEnabled = YES; // not needed but helpful // Now let's create each page UIScrollView *scrollPage1 = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; [scrollPage1 addSubview:theContentViewForPage1]; scrollPage1.contentSize = CGSizeMake(self.view.bounds.size.width, theContentViewForPage1.bounds.size.height); // Add page to scrollHorizontal [scrollHorizontal addSubview:scrollPage1]; [scrollPage1 release]; //...add more pages (REMEMBER to set the scroll view's frame.origin.x accordingly for each additional page) // Set the scrollHoriztonal content size scrollView.contentSize = CGSizeMake(self.view.bounds.size.width*NUMBER_OF_PAGES, self.view.bounds.size.height); // Now add the scrollview to self.view; or even self.view = scrollHorizontal, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With