UIScrollView and Multi-Touch zooming

Comments

[this is good]

Hi Alex,

Thanks for your post. I'm trying to create a UIScrollView subclass that handles zooming properly (i.e. doesn't alter the private zoomScale property of the content view, and indeed, doesn't assume there is only one single content view). To this end, I want to handle all two-touch gestures myself. I found that overriding UIScrollView's UIResponder methods was fine as far as it went, but that during the pinch movement the touches would be cancelled, even if I never called super on those overridden methods to pass the touches on to the UIScrollView!

Do you have any idea what mechanism is cancelling those touches? The behaviour doesn't seem to be that of the normal responder chain. NB I have been using 3.0, which has slightly different behaviour to
Oops, not sure where the second half of my post above got to. I was going to say, 3.0 has a different behaviour to <=2.2.1: as mentioned in the release notes UIScrollView's hitTest:withEvent: method now returns the proper subview rather than itself, and seemingly in support of this, the way that touches are cancelled is now handled completely differently. (Make a test project with a simple UIScrollView subclass (with a contentSize larger than its frame.size) that prints log messages from the touches*:withEvent: methods, with and without calling super, and see how its behaviour differs between 2.2.1 and 3.0.)

Best wishes,
Hamish

Interesting. I haven't been targetting 2.2.x so I didn't notice the difference in behavior. I don't have any issue with multi-touches gesture, though I am not trying to ignore UIScrollView's zoomScale property like you are.

I know this is a cop-out answer, but have you filed a bug report or feature request with Apple? This feels like UIScrollView is not fully flushed out w.r.t. more advanced scenarios.
The problem with UIScrollView is that it seems to have been designed in two separate halves: the scrolling mechanism being designed to allow for a content area greater than the maximum size of a view (hence contentSize rather than contentView) but the zooming mechanism assuming a single viewForZoomingInScrollView.

You're right, I should file a bug report / feature request. In fact I think I'm going to open a DTS request to find out how on earth the new touch cancellation mechanism works...

Post a comment

Already a Vox member? Sign in

Alex

About Me

Alex
United States
Hong Kong born British Chinese expat living in NY, gadgets loving, agile software developer working around the US
Digg:
CountZero75
Dopplr:
AlexHung
Facebook:
alex.y.hung
Flickr:
alexhung
Google Talk:
alex.y.hung@gmail.com
LinkedIn:
alexhung
Other:
http://www.ustream.tv/AlexHung
Other:
http://www.vimeo.com/alexhung
Twitter:
AlexHung
Yahoo!:
alexyhung
YouTube:
yfhung

My Groups

Neighborhood

Explore friends, family, friends & family, or entire neighborhood.

Archives