2
votes

I have been facing the same nested UIScrollView problem for long time.I tried some open source codes like Scrolling madness ,three-20 and others but all fails finaly.I am trying to make a photo Viewer application same as iPhone.For that I have created the structure like this:-

1)one View controller. 2)on view of view controller one UIScrollView (i.e inner/parent scroll view) as a child. 3)on inner/parent scroll view number of child scroll views(i.e. outer/child scroll views) ,each represents one page of photos application. 4)On each scroll view one image View on which i am displaying my image.

So what I want is when user scrolls the outer scroll view it should scroll horizontally with all the child views so I will get the look and feel of paging in photos application.Also when user is on one specific image(i.e. child/outer scroll view) he should be able to zoom in/out,swipes and perform single/double tapping.I was able to make it work in sdk 2.1,but it dosnt work since sdk 3.0.Please tell me the idea behind your project.Means which scroll view you are subclassing ,in which view to detect touches.How this completely child - parent relation should be. If possible provide any sample code also.

3

3 Answers

1
votes

There is a WWDC session from 2010 that deals with this very issue.

Here's the short of it:

You need a single scroll view that is paginated and scrolls horizontally. Each "page" of that scroll view is another scroll view containing a photo.

0
votes

First, it looks like you want to subclass UIScrollView? Every interaction method you need is provided for you in either the delegate callbacks or the touch methods. (Many of Apple's more advanced classes, such as UIScrollView, react poorly to subclassing.)

Second, it sounds like you have a first responder problem. IOW, your innermost scrollview isn't getting the first crack at the touch events.

Andrew

0
votes

I also struggled with this for a long time trying samples you mentioned. I could finally figure it out with the samples provided by apple (iphone dev center).

http://developer.apple.com/iphone/library/samplecode/Scrolling/Introduction/Intro.html

http://developer.apple.com/iphone/library/samplecode/ScrollViewSuite/Introduction/Intro.html

The first one is pretty basic and probably what u already have. The second one is all about zooming, etc. Just study these and the samples you already have, I think you will be able to figure it out. On specific topics just come back here search for answers or post another question.

EDIT: I forgot this one check out these examples by Andrey Tarantsov hosted on github. This is what you want... http://github.com/andreyvit/ScrollingMadness