Scrollview overriding button touch

Discussion in 'iOS Programming' started by mrl72, Jan 20, 2011.

  1. mrl72, Jan 20, 2011
    Last edited: Jan 20, 2011

    Expand Collapse
    macrumors regular

    Apr 20, 2008
    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?


    Edit: Nevermind, the button had a tag of zero changing this fixed the problem.
  2. robbieduncan
    Expand Collapse
    Moderator emeritus


    Jul 24, 2002
    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).

Share This Page