I ran into a very simple problem, but a quick Google search didn’t reveal any simple (or even functional) solutions.
Simply put, trying to use a date picker or picker control inside a scroll view leads to problems: trying to scroll the picker ends up scrolling the scroll view itself.
The solution is very simple: set the UIScrollView’s “canCancelContentTouches” property to NO.
Like a lot of Apple’s documentation, this part makes sense once you already know what it means…
If the value of this property is YES and a view in the content has begun tracking a finger touching it, and if the user drags the finger enough to initiate a scroll, the view receives a touchesCancelled:withEvent: message and the scroll view handles the touch as a scroll. If the value of this property is NO, the scroll view does not scroll regardless of finger movement once the content view starts tracking.
(from the docs).
I actually understood it a lot faster by just reading the comments in UIScrollView.h.
(tested in 3.0, haven’t tried 2.2.1 yet)




















#1 by Daniel at March 5th, 2010
Hi, thanks for your solution, seems so promising, yet, it didn’t actually solve my problem.
I have a UIDatePicker inside a UIScrollView, and whether I set the canCancelContentTouches to YES or NO, I still can’t use the date picker, it always starts the scrollview’s scrolling action.
The only way I can change date is by tapping…
Are you sure you didn’t add any other lines to make your date picker work in the scrollview?
#2 by Josh at March 23rd, 2010
I’m having the same problem Daniel’s having - I’m still unable to use my picker whether I set canCancelContentTouches to YES or NO, and the only way I can change the value is by tapping.
Was there more to your solution?
#3 by Phil Pearce at May 7th, 2010
Has anyone got this working?
#4 by Aaron at May 13th, 2010
I got mine to work by adding only the line of code he mentioned. Seems silly to mention this but: in order to get the picker control to move you must keep you finger on the picker control “a little longer” so the picker control gets the action and not the scrollview. From what I’ve read the scrollview works with a timer and if there is no swipe/flick by the time the timer fires the action is then passed to the underlying control.
Hope this helps.
#5 by Ian at June 17th, 2010
You also have to set: @property(nonatomic) BOOL delaysContentTouches to no
#6 by Kyle at August 13th, 2010
Thanks Ian, that worked great.