0
votes

I have a UIScrollView which I'm using as a container for two 'pages' of views. The first page contains two subviews: a kind of 'canvas' UIView subclass that the user can paint on with touches, and a 'control panel' UIView subclass full of UIControls. The scroll view itself has scrolling disabled (I'm using a UIPageControl to scroll it.)

The problem is this: when I tap on any of the controls in the control panel view they work fine. However, when I touch the canvas view, nothing happens. There are no controls on the canvas subview; it's just an empty UIView subclass that detects touches and draws points under the user's finger. (Previously this was all working fine; I've just recently put the two pieces in the scroll view.)

How can I tell the UIScrollView to forward touches to the canvas subview? I have set the scrollview so that Delays Content Touches and Cancellable Content Touches are off. User Interaction Enabled and Multiple Touch are both on.

I do not know whether to subclass the UIScrollView and change it's touch handling, or whether to override some other method in the canvas UIView subclass.

EDIT: Vince (commenter) prompted me to look at where the touch event handlers lived. They exist in the UIViewController subclass which owns the control panel view and the canvas view (and, now, the scroll view.) touchesBegan isn't being called anymore.

Thanks

1
does the subview subclass handle events ?user971401
@Vince, aha, you have something there. The View Controller had the touch handlers, not the view itself. Thanks!Tim
as the controller belongs to the responder chain, I believe it should handle them. strangeuser971401
@Vince, I thought so too. In fact, if I flip some of the scrollview's settings (the four I mentioned in the question) then it does forward the touches; the problem is that doing that prevents the control panel's UIControls from receiving touches. There's something wrong for sure. Thanks.Tim

1 Answers

0
votes

Are you using iOS 5? If so, try making use of the UIViewController Container APIs. If you have a ViewController with the UIScrollView and "child" view controller under it, you may linking issues. Try calling [self addChildViewController:theCanvasVC] in your controller for the scrollView.

I'm guessing at your architecture so i may be off. Let me know how your app is organized.

You can read up on Container View Controllers here. Scroll down to "Implementing a Container View Controller".