views:

379

answers:

3

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.

A: 

There technically is no such thing as vertical paging, only horizontal as of right now for the standard API. Up/down is scrolling, and paging left/right is a little different.

You should be able to disable vertical scrolling within Interface Builder after selecting the uiscrollview and editing its properties within the inspector window.

iWasRobbed
A: 

You can dynamically set the pagingEnabled to NO when the user zooms in, and then set it back to YES when they zoom out.

Check out the docs for UIScrollViewDelegate to learn how to detect zooming.

Michael Grinich
Thank you.But it is not enough, because I need horizontal paging during zooming.I want to only switch off paging of vertical.But I knew I can't turn off paging of vertical.So someone tell me advice.He said it is able to turn off vertical paging using 2 scrollView.One is whole pages with pagingEnabled=NO;Another one is only one page with pagingEnabled=YES;But my sample doesn't work correctly.Anyone please help me.
A: 

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.

Ephraim