PDA

View Full Version : Scrollview overriding button touch




mrl72
Jan 20, 2011, 11:35 PM
I have a weird issue where a button which is added as a subview of a scrollview, is reacting to touch events fine but in my buttonPressed:(id)sender method it's passing the tag of the main UIScrollView. I have a bunch of other buttons created in the exact same way (not in IB) and they work fine. Any ideas?

Cheers.

Edit: Nevermind, the button had a tag of zero changing this fixed the problem.



robbieduncan
Jan 21, 2011, 04:38 AM
Edit: Nevermind, the button had a tag of zero changing this fixed the problem.

I'm happy that you found the solution to this. As an aside all controls have a tag of 0 unless you explicitly set them to something else. As such I'd avoid giving a tag of zero any meaning (i.e. if you want to know which control is the scroll view don't set the scroll view to 0).